While debugging some jquery script ordering, we noticed the following and
I'm looking for views on why this is done:

1. Wicket assembles all ajax click handlers and writes them out into a
single Wicket.Event.add(window,"domready" function(event) { .... script
invocation written in to the <head> element of the page.
2. For things like click handlers, Wicket writes out Wicket.Ajax.ajax(
{"c": "selection4e2", "u":".....", "m":"POST"}) calls that execute within
the onDomReady function defined in (1)
3. This invocation of (2) in turn invokes jquery( fn );  This effectively
puts the function invocation back on the jquery event queue for onDomReady
processing
4. Any custom scripts that we added using OnDomReadyHeaderItem, regardless
of where we put them on the page after the standard Wicket click handler
JS, are now invoked, according to page order.
5. The re-queued functions from (3) now execute after my custom scripts.
These custom scripts modify the DOM (table paging/filtering etc) and this
mechanism now results in JS errors since the functions fail to find the
required elements in the DOM

Is this re-queueing intentional, and is there a reason that we couldnt just
execute the click handler additions in step (1) rather than re-queuing the
JS call?

Regards

Nick

Reply via email to