I’m trying to bind change event to model, but is not working. Here is the link: http://jsfiddle.net/kahhor/jp4B6/2/ . I think, I’m doing some stupid mistake, that I cannot figure out.
I think the problem is that it is two different views…
Sorry, new in backbone.js, just learning 🙂
Thanks,
update: I changed the way I call views and models:
/* MODELS */
var PopupM = new PopupModel();
var TaskbarM = new TaskbarModel();
var LeftNotificationM = new LeftNotificationModel();
/* /MODELS */
window.PopupView = new PopupView({model: PopupM, LeftNotificationModel: LeftNotificationM});
window.TaskbarView = new TaskbarView({model: TaskbarM});
window.TaskbarView.loadTaskbar();
window.LeftNotificationView = new LeftNotificationView({model: LeftNotificationM});
window.LeftNotificationView.loadLeftNotification();
Everything works fine, except when I’m calling decrementNotification()
this error message shows in Firebug:
this.LeftNotificationModel is undefined
this.LeftNotificationModel.decrementNotification();
But I already declared it here:
window.PopupView = new PopupView({model: PopupM, LeftNotificationModel: LeftNotificationM});
What I’m doing wrong here? 🙁
The way I see it you want to change the behaviors of two views based on the state of one model.
I’m not quite sure what
PopupModelwas supposed to do, so I omitted it.Essentially, you want to create one Model
LeftNotificationModeland pass that to both views within an option parameter.See the JSFiddle for a running example: http://jsfiddle.net/dj4cp/1/