While I really like the way how unobstructive jQuery is, there are some issues I kinda feel its complicating things, particularly when you try to do an AJAX app that renders some new links into your page and you need them to be binded again to events. For example, if you have an in-line edit form, you would have to do:
var bindRowEdit=function(scope) {$('link',scope).click()...}
var bindFormEdit=function(scope) {$('form').ajaxSubmit...}
Then each time when your new controls being rendered, you have to call this binding thing again. Looking at the obstructive way of using onclick or the url, while that might make your HTML looks a bit messy and longer, the result is kinda straightforward and easy to understand. I just hope there is something can have the best of both worlds.
Update: Ca Phun Ung, a great jQuery/PHP programmer I met in Barcamp HK, has written a post about event bubbling and also pointed me to the great jQuery livequery plugin, both are great solutions. I personally chosen livequery for my project and it works great.


3 comments:
Try event delegations! which is what the live plug-in is doing. But it's better to understand how it actually works than just simply applying the plug-in.
From my understanding seems livequery does rebinding instead of delegation (which I call it bubbling because basically it means the child bubble their event up to the parent element)
Bubbling/Delegation works, but I remember it also cause overheads as the event has to follow a bubble up path to the parent and could cause weird deadloop behavior in rare scenarios.
clement: by the way your website looks slick.
Post a Comment