I have a Marionette CompositeView with a search bar and a dataset of results.
I would like to call a function when:
- the search bar is displayed.
- collection is not yet displayed.
- this function cannot be called when rendering a collection.
I did it this way: (but the "afterRender" function is called twice)
App.MyComposite.View = Backbone.Marionette.CompositeView.extend({
template: Handlebars.compile(templates.find('#composite-template').html()),
itemView: App.Item.View,
itemViewContainer: '#collection-block',
initialize: function() {
this.bindTo(this,'render',this.afterRender);
},
afterRender: function () {
}
});
How can i do this?
=========================== EDIT ======================== ============
I solved it this way, if you have an observation, please let me know.
App.MyComposite.View = Backbone.Marionette.CompositeView.extend({
initialize: function() {
this.firstRender = true;
},
onRender: function () {
if (firstRender) {
this.firstRender = false;
}
}
});
source
share