Created
December 18, 2012 20:56
-
-
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 :)).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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