我在 Bloodhound 中使用 typeahead,我需要从 Bloodhound 获取调用者元素 ID。这是代码:
var destinations = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '/json/cities/1',
remote: {
url: "/json/cities/%COUNTRY/%QUERY",
replace: function (url, uriEncodedQuery) {
return url.replace('%QUERY', uriEncodedQuery).replace('%COUNTRY', $('#country_1').val());
},
},
limit: 30
});
destinations.initialize();
正如您所看到的,例如,我将 %COUNTRY 替换为,$('#country_1').val()
但我需要呼叫者 ID,获取索引,然后获取正确的 country_id。$('#country_+caller.getPartOfId()).val()
这是可能的吗?