for some reason I need to use a variable as the selector for events in backbone, but I can’t figure how to do this :
app.views.Selfcare = Backbone.View.extend({
events: {
click window.parent.document .close : "closeWindow"
},
closeWindow: function() {
//code
}
});
I have to use a different scope and I can’t do “click .close” : “closeWindow”.
Thx for your help.
I had a look at Backbone.js’s source code and found out that if your view’s
eventsis a function then the function is called and it’s return value is used as theeventsobject.This means that your code can be changed like this:
THIS is the interesting part of the source code:
Update:
Example is available on JSFiddle HERE**