Select2其他复选框未选中 [英] Select2 additional checkbox not checking

查看:133
本文介绍了Select2其他复选框未选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们.

我正在尝试在搜索框下方添加其他HTML元素.例如,出于过滤目的的复选框. 但是添加的复选框不起作用,您实际上无法对其进行检查.我不确定,但我认为搜索框正在吸引他们的注意力……我创建了此jsFiddle,以便大家可以查看.

I'm trying to add additional HTML elements below search box.. like checkboxes for filtering purposes. But the added checkbox is not functional, you can't actually check it. I'm not sure but I think that search box is taking the focus from them... I created this jsFiddle so you guys can check it out.

http://jsfiddle.net/6wz2hLh0/

$("#e1").select2();
//Inserting additional HTML elements below search... filter in my case
$(".select2-search").after("<input type='checkbox'/>");

当下拉列表打开时,您甚至无法编写jsFiddle输入的内容.

When the dropdown is open you can't even write in jsFiddle input's.

我尝试注释掉源代码中的各种焦点调用,但是没有运气.

I tried commenting out various focus calls from source code with no luck.

任何人都可以使我指向源代码中的正确方向,是什么导致这种不间断的搜索框聚焦.

Can any one point me in to right direction in source code what is causing this non stop search box focussing.

推荐答案

要尝试的一件事是让复选框元素阻止鼠标事件的传播.这似乎阻止了他们进入Select2,因此Select2无法杀死他们.

One thing to try is to have the checkbox element stop the mouse events from propagating. That seems to prevent them from getting to Select2, so Select2 cannot kill them.

$("<input type='checkbox'/>")
    .insertAfter(".select2-search")
    .on('mousedown mouseup click', function(e) { e.stopPropagation(); });

jsfiddle

这篇关于Select2其他复选框未选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆