I am creating custom events for a list of events. I have these events in a file (event.js) like this:
define(function(require, exports, module) {
module.exports = {
'event1': ['test1','data1'],
'event2': ['test2','data2']
};
});
I am creating event trigger for each of these events:
createTriggers: function(Events){ //Events = require(event.js);
_.defer(function(){
_.each(Events,function(data,event){
var events = function () { console.log("Data is "+this.data)};
events = _.bind(events,data);
targ.events.bind(event,events); //targ is the Backbone event object
});
});
}
But when I trigger any of the event:
this.trigger("event1");
I get output as Data is undefined. Why the values '['test1','data1']' is not fetched?