jQuery autocomplete 中文輸入 自動完成

autocomplete 中文輸入法的bug
原因是中文輸入時不會觸發原本在autocomplete 的keydown事件。

//fixed firefox and ie in IME bug
jQuery('#searchkey').bind( "input.autocomplete", function(){
             $(this).trigger('keydown.autocomplete');
})

或是用jQuery 綁定 text 事件即可解決:

 
var logFunc = function(){console.log($(this).val())}; 
$(':text').keyup(logFunc).bind('text', logFunc);

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s