agility
agility copied to clipboard
Add 'show' event when an object is added to a container
trafficstars
I've added a new event "show" that is dispatched on an object is added to a container and thus added to the DOM proper. Some use cases for this are:
- Running code only when the object is fully initialized and the model is ready
- Not running code for prototype objects that aren't meant to be used directly
Related issues: #52
Hello Pindi,
I like the idea of a show event!
I'm wondering though if there's a more robust way to make sure the element is indeed being displayed (i.e. attached to the document/DOM).
For example, in your test case, neither obj1 nor obj2 is appended to $$.document, so neither is actually "shown".
Perhaps the way to go about this is to add a hook into $$.document methods like .append() that traverses the hierarchy of sub-objects being appended/prepended/etc and then fire the corresponding show events?