jst*_*rdo 18 dialog jquery-select2
我在jquery对话框中使用select2插件但是没有用.下降时,焦点移动到输入控件但立即离开它,不允许我输入任何内容.
这是HTML:
<div id="asignar_servicio" title="Asignar servicios a usuarios">
<input type="hidden" class="bigdrop" id="a_per_id" />
</div>
Run Code Online (Sandbox Code Playgroud)
这是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;
});
Run Code Online (Sandbox Code Playgroud)
我在其他页面中有相同的代码,它的工作原理.
任何帮助将不胜感激,
谢谢Jaime
Jer*_*ght 25
jstuardo的链接很好,但在该页面上有很多要筛选的内容.这是您需要的代码:
$.ui.dialog.prototype._allowInteraction = function(e) {
return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop').length;
};
Run Code Online (Sandbox Code Playgroud)
只需将其添加到您设置select2下拉列表的任何位置.
一个简单的方法:
$.ui.dialog.prototype._allowInteraction = function (e) {
return true;
};
Run Code Online (Sandbox Code Playgroud)
在设置select2之后添加此项
| 归档时间: |
|
| 查看次数: |
19187 次 |
| 最近记录: |