gpt4 book ai didi

javascript - SumoSelect 处理事件不适用于 Android 设备

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:37 27 4
gpt4 key购买 nike

我正在使用 SumoSelect v3.0.3 在我的选择标签上(它使多选选项),但我在处理 Android 设备上的事件时遇到问题。关闭时选择标记 alert() 不会出现。

只需要在关闭相扑选择时调用我的函数或触发器。在 Android 和桌面上...

  • 适当的解决方案可以在旧的 3.0.2 版本中...

有一个工作 fiddle :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...

编辑 2:

使用初始设置 forceCustomRendering: true 所有触发器都有效...但我希望此设置为 false(默认)

最佳答案

您为什么要尝试使用 sumo 插件来触发?你到底想做什么?

例如你可以这样做

$(document).on('change', 'select.class', function(sumo) {
alert("Drop down closed!");
});

https://jsfiddle.net/5dy8j54n/14/

关于javascript - SumoSelect 处理事件不适用于 Android 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49161066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com