Created
September 18, 2012 16:30
-
-
Save laser/3744122 to your computer and use it in GitHub Desktop.
Difference in callback arguments when publishing via "triggers" mechanism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CollectionView + ItemView example | |
var MySubView = Marionette.ItemView.extend({ | |
"triggers": { | |
"click .save": "widget:saved" | |
} | |
}); | |
var MyCollectionView = Marionette.CollectionView.extend({ | |
"initialize": function(options) { | |
this.bindTo(this, "itemview:widget:saved", this._onWidgetSaved, this); | |
}, | |
"itemView": MySubView, | |
"_onWidgetSaved": function(view) { | |
// view is a reference to the ItemView in question | |
} | |
}); | |
// Layout + ItemView example | |
var MyLayoutView = Marionette.Layout.extend({ | |
"regions": { | |
"one": ".region.one" | |
}, | |
"onRender": function() { | |
var subView = new MyItemView(); | |
this.one.show(subView); | |
this.bindTo(subView, "widget:saved", this._onWidgetSaved, this); | |
}, | |
"_onWidgetSaved": function(view) { | |
// view is undefined... in fact, arguments is empty | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment