【发布时间】:2018-08-16 02:17:24
【问题描述】:
我在我的选择标签上使用SumoSelect v3.0.3(它提供多选选项),但我在处理 Android 设备上的事件时遇到了问题。关闭时选择标签alert()不出现。
只需要调用我的函数或在关闭相扑选择时触发。在 Android 和桌面上...
- 正确的解决方案可以在较旧的 3.0.2 版本中...
有一个工作小提琴:LINK - 在桌面上打开和关闭选择输入之后,您可以看到一个带有“下拉关闭!”的警报窗口文本,但在 android 设备上你不会...
// .class pointing to <select> tag
$('.class').SumoSelect({placeholder: 'Select choice'});
$('select').on('sumo:closed', function(sumo) {
alert("Drop down closed!");
});
在桌面 (Firefox/Chrome) 上它可以工作...有什么建议吗?
我在 javascript/jquery 方面很弱,但在以前的版本 (3.0.2) 中,我有自己的触发器 $(document).trigger('sumoCloseSelect'); 直接在 sumoselect.js 插件中,就像这样(最后一行):
showOpts: function () {
var O = this;
if (O.E.attr('disabled')) return; // if select is disabled then retrun
O.is_opened = true;
O.select.addClass('open');
if(O.ftxt)O.ftxt.focus();
else O.select.focus();
// hide options on click outside.
$(document).on('click.sumo', function (e) {
if (!O.select.is(e.target) // if the target of the click isn't the container...
&& O.select.has(e.target).length === 0){ // ... nor a descendant of the container
if(!O.is_opened)return;
O.hideOpts();
$(document).trigger('sumoCloseSelect');
(是的,很脏)然后在我的 main.js 文件中:
$(document).on('sumoCloseSelect', function(e) {
alert('Drop down closed!');
...
但是这个解决方案也不适用于 android...
编辑:
我尝试将以下内容添加到 sumoselect js 文件 jQuery.myFunction();(如上一个)并在自己的 js 中定义它
jQuery.myFunction= function(){
alert('yep!');
};
同样适用于台式机,但不适用于 Android...
EDIT2:
使用初始化设置 forceCustomRendering: true 所有触发器都可以工作...但我希望在 false 上设置此设置(默认)
【问题讨论】:
标签: javascript android jquery plugins sumoselect.js