-1
我正在尝试设置通过引导标签输入标签,但它不工作添加标签,并给予下列错误:在引导标签输入动态工作不
TypeError: b.options.itemValue(...) is undefined
我的代码如下:
$('#searchGeoBottom').tagsinput({
maxTags: 5,
delay: 500,
itemValue: 'value',
itemText: 'text',
typeahead: {
displayKey: 'text',
source: function (query) {
if (ajax) {
ajax.abort();
}
var data = {term: query};
ajax = $.getJSON((baseUrl + "geoSearch"), data);
return ajax;
},
afterSelect: function() {
this.$element[0].value = '';
}
}
});
if (typeof searchGeo != 'undefined' && searchGeo != '') {
$('#searchGeoBottom').tagsinput('add', searchGeo);
}
我也尝试下面的方法,我发现,当搜寻:
var elt = $('#searchGeoBottom').tagsinput({....});
elt.tagsinput('add', searchGeo);
但它并不能工作,给ELT没有定义或ELT不是一个函数..
以下是JSON我传递在增加功能:
[{"text":"Lahore. United States","value":4768156}]
你能包括你的问题jsfiddle吗? –
@AshiqurRahman让我尝试包含jsfiddle,我也更新了我的问题,请检查它是否有助于您理解问题。谢谢! –