在某处可以找到任何可行的示例吗?Typeahead 运行良好,但是当我尝试将 Bloodhound 连接到它时,我总是收到错误
未捕获的类型错误:无法读取未定义的属性“标记器”
在我的 Backbone-main.js 中,我定义了一个
path: {...,
typeahead: 'libs/typeahead.jquery.min',
bloodhound: 'libs/bloodhound.min',
}
和
shim: { ...,
'typeahead': {
'deps': ['jquery'],
'exports': 'jquery' // Make sure the noconflict configuration of jquery doesn't break this extension
},
'bloodhound':{
'deps': ['jquery'],
'exports': 'jquery' // Make sure the noconflict configuration of jquery doesn't break this extension
},
}
在我的 Backbone.view 我定义
define(['backbone', 'typeahead', 'bloodhound', '../models/searchableDocument', '../collections/searchableDocuments', 'text!./asset_footer.html'],
function(Backbone, Typeahead, Bloodhound, SearchableDocument, SearchableDocuments, footerTmpl) { ...
//.../initialize/...
var docHound = new Bloodhound({
name: 'documents',
local: this.allDocuments.toJSON(),
datumTokenizer: function(doc) { return Bloodhound.tokenizers.whitespace(doc.name); },
queryTokenizer: Bloodhound.tokenizers.whitespace
});
docHound.initialize();
...
我还在我的系统结构中包含了 Bootstrap (2.3.2),所以我也尝试通过使用来解决可能的冲突
...
var DocHound = Bloodhound.noConflict();
var docHound = new DocHound({
...
但这只会引发错误
未捕获的类型错误:无法调用未定义的方法“noConflict”
所以它看起来更像是我根本没有“接触”到猎犬类……有什么提示吗?谢谢!