我正在使用 Select2 插件,但是当插件与 jQuery 模态对话框一起使用时,内置的搜索功能不起作用。我有一个小提琴,显示问题在......
http://jsfiddle.net/jeljeljel/s3AFx/
请注意,搜索框不会接受焦点。_allowInteraction 事件(http://api.jqueryui.com/dialog/#method-_allowInteraction)应该有一个解决方法,但它对我不起作用。
谁能帮忙看看如何使这个小提琴工作?
此外,这篇 SO 帖子(当不在 jquery 模态对话框中时 select2 插件工作正常)讨论了同样的问题,但建议的修复对我不起作用。
HTML
<div class="dialog">
<select>
<option>A tall ship was seen a</option>
<option>A tall ship was seen b</option>
<option>A tall ship was seen c</option>
<option>A tall ship was seen d</option>
<option>A tall ship was seen e</option>
<option>A tall ship was seen f</option>
</select>
</div>
JAVASCRIPT
$('.dialog').dialog({
modal: true,
_allowInteraction: function (event) {
return !!$(event.target).is(".select2-input") || this._super(event);
}
});
$('select').select2();