javascript - Merging Event definitions for mixins and Views backbone.js -
i've created mixin backbone , i'm wondering if there better way merge events hash.
mixin:
app.mixin.filter = { events: { 'click .label': 'toggle', 'keyup .file-search': 'updatesearchfilter' }, //more stuff }
view:
app.dashboardview = backbone.view.extend({ el: '.contentwrap', dashevents: {'click .project-btn': 'addprojectmodal'}, initialize: function() { //other stuff _.defaults(app.dashboardview.prototype.events, this.dashevents); //other stuff } } _.extend(app.dashboardview.prototype, app.mixin.filter);
i'm particularly not happy calling event hash dashevents. there way can keep events 'events'? or there standard pattern handle kind of issue?
app.dashboardview = backbone.view.extend({ el: '.contentwrap', events : _.extend({}, app.mixin.filters.events, { 'click .project-btn': 'addprojectmodal' }) }
Comments
Post a Comment