-
-
Save theseyi/27ba67996fbd66969830 to your computer and use it in GitHub Desktop.
This file contains 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
ItemView = Marionette.ItemView.extend({ | |
// ... | |
onShow: function(){ | |
// I am guaranteed to be called from the CollectionView | |
// because the CollectionView registers me in a promise | |
} | |
}); | |
CollectionView = Marionette.CollectionView.extend({ | |
initialize: function(){ | |
this.onShowCallbacks = new Marionette.Callbacks(); | |
}, | |
onShow: function(){ | |
this.onShowCallbacks.run(); | |
}, | |
appendHtml: function(cv, iv){ | |
cv.append(iv.el); | |
// promise to run 'onShow' if it exists | |
if (iv.hasOwnProperty("onShow")){ | |
this.onShowCallbacks.add(iv.onShow); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment