Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 20:56
Show Gist options
  • Save anonymous/4331908 to your computer and use it in GitHub Desktop.
Save anonymous/4331908 to your computer and use it in GitHub Desktop.
very simple approach to using jQuery UI's autocomplete. This is very *rough* and is just meant to give you an idea of how you might use th autocomplete widget with a Backbone View (use only as a start :)).
var AutocompleteView = Backbone.View.extend({
initialize: function() {
this.availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
}
render: function() {
this.$el.html('<input id="tags">');
this.$el.find('#tags')..autocomplete({
source: this.availableTags
});
});
var view = new AutocompleteView();
$('body').append(view.render().el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment