我在选择标签上使用SumoSelect v3.0.3 (它提供多选择选项),但我在处理安卓设备上的事件时遇到了问题。在关闭选择标记时,不会出现alert()。
只需要任何调用我的功能或触发关闭相扑选择。在安卓和桌面上..。
有一个工作的小提琴:链接 -打开和关闭选择输入,然后在桌面上,你可以看到一个警报窗口‘下拉关闭!短信但在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)中,我在类似于下面(最后一行)的sumoselect.js插件中直接使用了自己的触发器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文件jQuery.myFunction();中(类似于prev )。在自己的js中定义它
jQuery.myFunction= function(){
alert('yep!');
};再一次,对于桌面来说,它是有效的,但对Android却不行.
EDIT2:
在init设置forceCustomRendering: true所有触发器工作..。但我希望在false上设置此设置(默认设置)
发布于 2018-03-31 19:17:54
你为什么要用相扑插件来抓扳机?你到底想做什么?
例如,你可以这样做。
$(document).on('change', 'select.class', function(sumo) {
alert("Drop down closed!");
});https://stackoverflow.com/questions/49161066
复制相似问题