Working in Backbone.js, I'd like to set a model property from within a method on the model. This seems like it should be simple, but I can't get it to work.
Currently what I have is this. I'm trying to set the 'results' property during a call to 'performSearch':
var SearchModel = Backbone.Model.extend({
performSearch: function(str) {
$.get('/' + str, function(results) {
console.log(data);
this.set("results", data);
});
},
});
This gives me the following error:
Uncaught TypeError: Object #<Object> has no method 'set'
What am I doing wrong?