I’m getting an error ‘Object [object Object] has no method ‘apply” in the console. Please see fiddle..
http://jsfiddle.net/vineet85/AQx63/6/
var RefreshingView = new Backbone.View.extend({
initialize: function() {
this.model.on('change', this.render, this);
},
render: function() {
this.$el.html(this.model.get('text'));
}
});
var m = new Backbone.Model({text: new Date().toString()});
var myView = new RefreshingView({model: m, el: 'body'});
myView.render();
setInterVal(function() {
m.set({text: new Date().toString()});
}, 1000);
Your syntax is a bit off, first for “declaring” your views and models you should leave out the new keyword, second you shouldn’t be trying to “instantiate” the backbone.js model directly, try the following instead
Updated jsFiddle