在jqueryUI 的dialog中使用select2,select2的input search無論怎樣都獲取不到焦點?
解決方法:
$(document).ready(function () {
$.widget("ui.dialog", $.ui.dialog, {
//解決Dialog控件使用select2不出現光標的問題
open: function () {
return this._super();
},
_allowInteraction: function (event) {
return !!$(event.target).is(".select2-search__field") || this._super(event);
}}
);
var user_select2_option = {
ajax: {
url: "/util/account",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term
};
},
processResults: function (data, page) {
return {
results: data.items
};
},
cache: true
},
allowClear: true,
minimumInputLength: 2
};
$(".user-select2").select2(user_select2_option);
delete user_select2_option['allowClear'];
});
