jquery ui dialog 中使用select2 導致select2的input失去焦點的解決方法
阿新 • • 發佈:2019-02-04
在jqueryUI 的dialog中使用select2,select2的input search無論怎樣都獲取不到焦點?
解決放方法:去掉diaog中的modal: true,便可
網上看過不少答案:有說將dialog ui 的tabindex=-1去掉就行,但我的程式碼中此方法不起作用。$("#addAndEditDiv").dialog({ autoOpen: false, width: 1000, height: 600, //modal: true, resizable: false, draggable: true, title: title, buttons: { "確定": function () { }, "取消": function () { $(this).dialog("close"); } }, }); $("#addAndEditDiv").dialog('open');
若此方法不能解決你的問題,可以參考:點選開啟連結(http://stackoverflow.com/questions/16966002/select2-plugin-works-fine-when-not-inside-a-jquery-modal-dialog)