When utilizing typeahead bootstrap, my goal is to trigger an action when an item is selected or focused from the menu, allowing me to assign a specific value connected to the selected item.
To fully grasp my intention, please refer to the comments within the code snippet provided below:
element.typeahead({
minLength: 3,
source: function () {
// users refers to a Backbone.Collection
users = _.map(users, function(user) {
return user.get('first_name')+' '+user.get('last_name');
});
return users;
}
}).change(function (event) {
// This particular function gets executed once a user has set a value.
// It needs to access the user.get('id') of the selected user.
// Any suggestions on how this can be achieved?
});