当不在jQuery模式对话框中时,select2插件可以正常工作 [英] select2 plugin works fine when not inside a jquery modal dialog
本文介绍了当不在jQuery模式对话框中时,select2插件可以正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在jquery对话框中使用select2插件,但无法正常工作。下拉时,焦点移至输入控件,但立即退出输入控件,不允许我键入任何内容。
I am using select2 plugin inside a jquery dialog but in does not work. When dropping down, the focus moves to the input control but immediately get out from it,not allowing me to type anything.
这是HTML:
<div id="asignar_servicio" title="Asignar servicios a usuarios">
<input type="hidden" class="bigdrop" id="a_per_id" />
</div>
这是JavaScript代码:
And this is the javascript code:
$( "#asignar_servicio" ).dialog({
autoOpen: false,
height: 500,
width: 450,
modal: true,
buttons: {
"Cancelar": function () {
$('#asignar_servicio').dialog('close');
}
}
});
$("#a_per_id").select2({
placeholder: "Busque un funcionario",
width: 400,
minimumInputLength: 4,
ajax: {
url: "@Url.Action("Search", "Personal")",
dataType: 'json',
data: function (term, page) {
return {
q: term,
page_limit: 10,
};
},
results: function (data, page) {
return { results: data.results };
}
}
}).on("change", function (e) {
var texto = $('lista_personal_text').val().replace(/ /g, '');
if (texto != '')
texto += ',';
texto += e.added.text;
var ids = $('lista_personal_id').val().replace(/ /g, '');
if (ids != '')
ids += ',';
ids += e.added.id;
});
我在其他页面中也有相同的代码,并且可以正常工作。
I have this same code in other page and it works.
任何帮助将不胜感激,
感谢
Jaime
thanks Jaime
推荐答案
我已经找到了解决方法。 https://github.com/ivaynberg/select2/issues/1246
I have found this workaround. https://github.com/ivaynberg/select2/issues/1246
欢呼
詹姆斯
这篇关于当不在jQuery模式对话框中时,select2插件可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文