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

Notifications before and after DOM node replacement

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.5-RC4
    • 1.5-RC5
    • wicket
    • None

    Description

      Sometimes JavaScript libraries need to listen for some events on DOM nodes and they register their listeners. Later Wicket can replace such components (or their parent nodes) and the JavaScript listener will stop working.
      By adding notification before the replacement like
      Wicket.DOM.callNodeChangeListeners('changing', element);

      and another one after:
      Wicket.DOM.callNodeChangeListeners('changed', newElement);
      where 'newElement' is the newly created element gives a chance to the JS library to react.

      The code above was my first attempt. Then I realized that custom JS events will be much better, but it appears IE doesn't support "unknown" events. There are workarounds like http://stackoverflow.com/questions/5342917/custom-events-in-ie-without-using-libraries but this code uses custom node traversal for event attaching as well which bothers me, I'm not sure what is the performance difference.

      So now I'm back on the approach with registered handlers but I think it will be better if it is made general. By passing the 'eventType' (like "wicket.dom.node.remove") as a parameter to the handler it may decide whether to react. Otherwise now we have pre/post/failure handlers for Ajax and who knows what else will be needed in the future.

      Attachments

        1. wicket-3782.patch
          2 kB
          Martin Tzvetanov Grigorov
        2. wicket-3782.patch
          4 kB
          Martin Tzvetanov Grigorov

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            mgrigorov Martin Tzvetanov Grigorov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: