autocomplete在Firefox下用中文檢索

在jquery.ui.autocomplete.js文件中,相應的位置添加(測試可行)下面的代碼

            //火狐 中文檢索
    .bind( "input.autocomplete", function( event ) {
                if ( suppressKeyPress ) {
                    suppressKeyPress = false;
                    event.preventDefault();
                }
                clearTimeout( self.searching );
                self.searching = setTimeout(function() {
                    // only search if the value has changed
                    if ( self.term != self.element.val() ) {
//                       console.log("self.term="+self.term+" self.element.val="+self.element.val());
                        self.selectedItem = null;
                        self.search( null, event );
                    }
                }, self.options.delay );
            })

設置option的minLength,可以在刪除輸入關鍵詞後自動搜索所有的

options: {
        appendTo: "body",
        autoFocus: false,
        delay: 300,
        minLength: 0,
        position: {
            my: "left top",
            at: "left bottom",
            collision: "none"
        },
        source: null
    },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章