Utilities that didn't make util.js

There a number of utilities that didn't make it into DWRUtil proper. They may evolve into something more useful, they may solve a niche need that you have, but they're not general purpose enough to warrant the network time for everyone.

Fixing Explorer Events

If you create a DOM element using addAttribute to create events, then they won't fire properly. You can use this script to run over a DOM tree and re-attach event attributes so they fire properly.

Change 'click' to be the event you wish to fix.

dwr.engine._fixExplorerEvents = function(obj) {   
  for (var i = 0; i < obj.childNodes.length; i++) {
    var childObj = obj.childNodes [i];
    if (childObj.nodeValue == null) {
      var onclickHandler = childObj.getAttribute('onclick');
      if (onclickHandler != null) {
        childObj.removeAttribute('onclick');
        // If using prototype:
        //   Event.observe(childObj, 'click', new Function(onclickHandler));
        // Otherwise (but watch out for memory leaks):
        if (element.attachEvent) {
          element.attachEvent("onclick", onclickHandler);
        }
        else {
          element.addEventListener("click", onclickHandler, useCapture);
        }
      }
      dwr.engine._fixExplorerEvents(childObj);
    }
  }