我在Bootstrap模式中實例化了Chosen插件。我在啓動模式之後調用Chosen插件。jQuery選擇插件 - 激活(即焦點)不工作?
除了能夠自動將元素自動對焦以允許在沒有首先點擊元素的情況下進行打字之外,所有的預期工作都是如此。奇怪的是,我得到了一個藍色的邊框,表明它有焦點,但沒有按鍵實際上註冊,直到我點擊進入對象。
我只需要這個爲Chrome工作,我目前正在運行版本39.0.2171.95。
我下面從文檔說明:
下面的代碼:
var $modal = $('#' + modalId); // This element contains relevant modal markup along with <select> element
$modal.modal();
var $mySelect = $('#mySelectElement'); // id of the <select> element
$mySelect.chosen();
$mySelect.trigger('chosen:activate'); // This doesn't work...
也試過以下,但無濟於事:
$mySelect.trigger('chosen:open'); // This doesn't work...
任何指針讚賞。
乾杯, 李
這是一個很好的解決方案,但研究模態在淡入淡出動畫完成後是否有觸發事件或回調。 –
謝謝Eduardo,已經按照你的建議去做了。答案已更新。 –