Skip to content

Instantly share code, notes, and snippets.

@chadedrupt
Created April 10, 2013 06:12
Show Gist options
  • Save chadedrupt/5352196 to your computer and use it in GitHub Desktop.
Save chadedrupt/5352196 to your computer and use it in GitHub Desktop.
Bootstrap Typeahead Custom Knockout Binding
ko.bindingHandlers.typeahead = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
$(element).typeahead();
},
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
var value = ko.utils.unwrapObservable(valueAccessor());
$(element).data('typeahead').source = value;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment