Closed miketeix closed 10 years ago
This sounds like more of a Marionette issue. Can you not use collection:rendered
? https://github.com/marionettejs/backbone.marionette/blob/master/src/marionette.collectionview.js#L87
In theory the models should be added in a .reset
all at once when you change filters. Am I missing something? https://github.com/jmorrell/backbone-filtered-collection/blob/master/index.js#L68
If that doesn't solve your problem, can you speak a bit more about what you're trying to do? I could add a filtered:done
event or similar, but I want to make sure I understand the use case.
Unfortunately neither onCollectionRender
nor onCompositeRender
are fired once I filter, although I know they're working because they both fire when I first render the Composite View
.
Oddly, I can hook into the Collection reset
event, but because it doesn't trigger the CollectionView render
event, only the ItemView render events, I have no idea when all the views are re-rendered.
I can always, re-render the whole CompositeView
, but I'd be rendering views essentially twice.
Perhaps its a Marionette thing - I thought that if the collection resets that the CompositeView
would be listening and re-render.
I don't think filtered:done
would do me any good, as it would be the same as the Collection reset
event which I have. My use case is typical I'd imagine - I've got a collection of slides that are being filtered, after the collection is reset, I'd like to re-render the CompositeView as a whole, but instead am rendering the individual ItemViews. I need to know when they've all finished rendering because I need to re-initialize a Slider plugin at that point.
So I found a decent enough workaround for my purposes without having to re-render my composite view manually.
onCompositeRendered
is still mysteriously not firing,
and oddly, neither is onCollectionRendered
but I just discovered onCompositeCollectionRendered
is firing after applying the filter, and it fires after all the individual views have been rendered, which is what I need.
Thanks for getting back to me, and for putting together this sweet plugin. I'm looking forward to using it finally.
Hi there,
Currently, when I add a filter to my obscura collection, the filtered models are being rendered into views one by one, and not by the CompositeView as a collective whole.
I need an event hook for when all the views have finished rendering, and because itemViews are being rendered individually, I don't have a way of knowing when that is.
Collection/Composite views have various onRender events that I could use, except they're not being triggered.