mbest / knockout

My enhancements to Knockout
35 stars 4 forks source link

use events for DOM-related notification #3

Open mbest opened 12 years ago

mbest commented 12 years ago

afterRender, afterAdd, and beforeRemove are Knockout events, but are not handled as DOM events. Thus you have to handle them through a special binding.

I propose that these be changed to trigger events either through the DOM interface or through jQuery using ko.utils.triggerEvent. ko.utils.triggerEvent will need a change, though, to allow for custom data to be passed along with the event. For backwards compatibility, the afterAdd, etc. binding can be set up to listen for the equivalent event.

mbest commented 12 years ago

Ryan brought up a good point in https://github.com/SteveSanderson/knockout/issues/234. The event should be triggered on the child element, which will then bubble up to the parent.