ripplejs / ripple

A tiny foundation for building reactive views
http://ripplejs.github.io
1.28k stars 66 forks source link

Emit "mounted" event on child views #31

Open UhhhWaitWhat opened 10 years ago

UhhhWaitWhat commented 10 years ago

According to this documentation, a mounted event should be triggered, each time a view enters the DOM.

This implies, that each time a view is mounted, each of its child views (attached via .compose()) should emit a mounted event as well.

Currently this is not the case. I will look into this (I guess it should be fairly straightforward to implement this) and see if I can provide a pull-request, but for now I wanted to know your opinions of this, and if this would be indeed the correct, expected behavior.

Sorry about issue #30, I would have preferred to attach the PR to it, but apparently I am not quite familiar enough with github to do that. Therefore I closed #30 and continue here.

bmcmahen commented 9 years ago

@anthonyshort any chance this could be added? Seems like a fairly significant bug & something I just ran into myself.

bmcmahen commented 9 years ago

So it actually works perfectly fine. The key (which is stupidly obvious) is that you need to attach the ripple element to the DOM using one of the view's dom manipulation methods (i.e., view.appendTo(document.body)).

anthonyshort commented 9 years ago

Yeah you have to use the methods otherwise the events won't be called. I could use mutation observers to see when the element gets added in anyway which would be kinda nice.