Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5747

Wicket Ajax Click handling gets requeued in OnDomReady so fire out of order

    Details

      Description

      While debugging some jquery script ordering, we noticed the following and I'm looking for views on why this is done and/or if it's a bug:

      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 requeues the function invocation at the back of 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 Wicket JS errors since the Wicket click handler binding 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?

      A workaround for this is to wrap all of our application JS functions in a separate jQuery( ... ) invocation, so that we can requeue all of our functions after all the requeued Wicket ones. It works, but we dont understand the need for Wicket to perform this requeueing instead of just executing the function as and where defined on the page.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mgrigorov Martin Grigorov
                Reporter:
                nickpratt Nick Pratt
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: