gpt4 book ai didi

dialog - 当不在jQuery模式对话框中时,select2插件可以正常工作

转载 作者:行者123 更新时间:2023-12-03 13:16:07 24 4
gpt4 key购买 nike

我在jquery对话框中使用select2插件,但无法正常工作。下拉时,焦点移至输入控件,但立即从中移出,不允许我键入任何内容。

这是HTML:

<div id="asignar_servicio" title="Asignar servicios a usuarios">
<input type="hidden" class="bigdrop" id="a_per_id" />
</div>


这是javascript代码:

        $( "#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;
});


我在其他页面中有相同的代码,并且可以正常工作。

任何帮助将不胜感激,

谢谢
海梅

最佳答案

jstuardo的链接很好,但是在该页面上有很多筛选内容。这是您需要的代码:

$.ui.dialog.prototype._allowInteraction = function(e) {
return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop').length;
};


只要将其添加到要设置select2下拉菜单的位置旁边即可。

关于dialog - 当不在jQuery模式对话框中时,select2插件可以正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16966002/

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