Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The render:children event should be renamed show:children #3604

Open
paulfalgout opened this issue May 10, 2018 · 1 comment
Open

The render:children event should be renamed show:children #3604

paulfalgout opened this issue May 10, 2018 · 1 comment
Milestone

Comments

@paulfalgout
Copy link
Member

This event is analogous to the region's show event. What it describes is that children were attached to the collection view. Yes, if they weren't already rendered they were rendered, but children only get rendered once, so for the most part unless children are added to the view, no child is rendered at all on subsequent triggers of this event after the first instance

https://jsfiddle.net/smgpw05w/

const myCollection = new Backbone.Collection([{ num: 4 }, { num: 2 }, { num: 1 }, { num: 3 }]);

const myCollectionView = new CollectionView({ collection: myCollection });

function countRenders(event) {
  let count = 0;

  this.children.each(child => {
    if(child.isRendered()) count++;
  });
  console.log(event + ' : ' + count);
}

myCollectionView.on({
  'before:render:children': _.partial(countRenders, 'before:render:children'),
  'render:children': _.partial(countRenders, 'render:children')
});

someRegion.show(myCollectionView);
// before:render:children : 0
// render:children : 4

myCollectionView.setComparator('num');
// before:render:children : 4
// render:children : 4
@paulfalgout paulfalgout added this to the v5 milestone May 10, 2018
@ribeiropaulor
Copy link

It makes sense! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants