Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // VIEW
- App.MyComposite.View = Backbone.Marionette.CompositeView.extend({
- // TEMPLATE
- template: Handlebars.compile(templates.find('#composite-template').html()),
- // ITEM VIEW
- itemView: App.Item.View,
- // ITEM VIEW CONTAINER
- itemViewContainer: '#collection-block',
- //INITIALIZE
- initialize: function() {
- this.bindTo(this,'render',this.afterRender);
- },
- afterRender: function () {
- //THIS IS EXECUTED TWICE...
- }
- });
- // VIEW
- App.MyComposite.View = Backbone.Marionette.CompositeView.extend({
- //INITIALIZE
- initialize: function() {
- //this.bindTo(this,'render',this.afterRender);
- this.firstRender = true;
- },
- onRender: function () {
- if (firstRender) {
- //DO STUFF HERE..............
- this.firstRender = false;
- }
- }
- });
- // VIEW
- App.MyComposite.View = Backbone.Marionette.CompositeView.extend({
- // TEMPLATE
- template: Handlebars.compile(templates.find('#composite-template').html()),
- // ITEM VIEW
- itemView: App.Item.View,
- // ITEM VIEW CONTAINER
- itemViewContainer: '#collection-block',
- //INITIALIZE
- initialize: function() {
- // this.bindTo(this,'render',this.afterRender); // <-- not needed
- },
- onRender: function () {
- // do stuff after it renders, here
- }
- });
- NoItemsFoundView = ItemView.extend({
- // ...
- });
- CompositeView.extend({
- emptyView: NoItemsFoundView
- });
- CompositeView.extend({
- onRender: function(){
- if (this.collection && this.collection.length === 0) {
- // do stuff here because the collection was not rendered
- }
- }
- });
- Backbone.Marionette.ItemView.extend({
- onShow: function(){
- // react to when a view has been shown
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement