I am in the process of learning Backbone.js. I currently assume that if one is using Backbone.js then all client-side javascript/jQuery should be integrated with Backbone. From
In my view, the collection with the data is accessed using this.collection
, like @saniko i set up the autocomplete in the view's render
function:
render : function() {
...
var me = this; //Small context issues
this.$el.find('input.autocompleteSearch').autocomplete({
source : function(request, response){
me.collection.on('reset', function(eventname){
var data = me.collection.pluck('name');
response(data); //Please do something more interesting here!
});
me.collection.url = '/myresource/search/' + request.term;
me.collection.fetch();
}
});
...
},
...