通过使用预先输入引导程序,我想在从菜单中选择或聚焦某个项目时触发,以便设置与所选值相关的特定值。
请查看代码注释以准确理解我的意思。
element.typeahead({
minLength: 3,
source: function () {
// users is a Backbone.Collection
users = _.map(users, function(user) {
return user.get('first_name')+' '+user.get('last_name');
});
return users;
}
}).change(function (event) {
// this function which is called when the user set a value
// should be able to get the user.get('id') of the selected user
// any idea how to make it?
});