arturadib / agility

Javascript MVC for the "write less, do more" programmer
http://agilityjs.com
MIT License
542 stars 70 forks source link

Add 'show' event when an object is added to a container #84

Open pindia opened 12 years ago

pindia commented 12 years ago

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:

Related issues: #52

arturadib commented 12 years ago

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?