0

我正在使用 twitter 的 Bloodhound 建议引擎,以下是我正在使用的代码片段

// instantiate the bloodhound suggestion engine
    var searchData = new Bloodhound({
        datumTokenizer: function (d) {
            return Bloodhound.tokenizers.whitespace(d.value);
        },
        queryTokenizer: Bloodhound.tokenizers.whitespace,        
        remote: {
            url: 'http://localhost/address/fetch?q=%Query' //Local URL           
        }
    });
    // initialize the bloodhound suggestion engine
    searchData.initialize();
    // instantiate the typeahead UI
    $('.typeahead').typeahead({        
        hint:false,
        highlight: true,
        minLength: 3
        }, {
        name:'search-data',
        displayKey: 'title',
        source: searchData.ttAdapter(),       
        templates: {            
            suggestion: Handlebars.compile('<p><strong>{{title}}</strong></p>')            
        }        
    });

Ajax 请求没有触发我在上面的代码片段中提到的内容,如果页面中不包含 jQuery Validation 插件,那么它工作正常。

如何克服这个问题?

更新:

我已经将 jQuery 验证插件从 1.7 升级到最新(1.12)然后它解决了这个问题,但我不知道这背后的原因是什么。如果有人知道确切原因,请发布答案。

4

1 回答 1

0

只需在 js 脚本顶部输出他的代码

 jQuery.noConflict( true )
    //or
$.noConflict( true )
于 2014-04-19T10:35:35.550 回答