选择(twitter)typeahead建议后,我无法设置文本字段的值
这不起作用:
$("#location").on("typeahead:selected", function(eventObject, suggestion, name) {
console.log(suggestion.stop_id);
$("#location").val(suggestion.stop_id);
});
虽然这有效:(但我想在同一文本字段中输入文字)
$("#location").on("typeahead:selected", function(eventObject, suggestion, name) {
console.log(suggestion.stop_id);
$("#destination").val(suggestion.stop_id);
});
必须在typeahead的显示参数函数中使用return suggestion.value替换return null,以在字段中输入所需的值。