选择(微博)提前输入建议后,我无法设置文本字段的值
这不起作用:
$("#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);
});
答案 0 :(得分:0)
必须在typeahead的显示参数函数中将return null替换为return proposal.value才能在字段中输入所需的值。