[Dojo-interest] Widget-less question.

Robert r. Sanders robert.sanders at ipov.net
Fri Sep 29 09:06:30 MDT 2006


Karl,
    Thanks; in the mean time I ended up copying and modifing some of the 
DomWidget's code into my own class to handle the issue.  If someone has 
a cleaner solution I'll switch to it (and maybe one will be incorporated 
into 0.4).  In the mean time:

/** A recursive function to find any dojoAttachEvent attributes and 
handle them. */
    scanTag : function (pNode) {
       var nodes = pNode.childNodes;
       if (null == nodes) {
           dojo.debug("Node has no child nodes!");
           return;
       }

       var i, atch, evts;
       for (i = nodes.length - 1; i >= 0; i--) {
           if (nodes[i].nodeType != dojo.dom.ELEMENT_NODE) {
               continue;
           }
           //dojo.debug("Found node [" + nodes[i].nodeName + "]");
           atch = nodes[i].attributes.getNamedItem('dojoAttachEvent');
           if (null != atch) {
               nodes[i].removeAttributeNode(atch);
               evts = atch.value.split(";");
               //dojo.debug("AttachEvents found! Values are: [" + evts + 
"]");

               //The following is copied from 
dojo.widgets.DomWiget#attachTemplateNodes line 202
               for (var y=0; y<evts.length; y++) {
                   if((!evts[y])||(!evts[y].length)){ continue; }

                   var thisFunc = null;
                   var tevt = evts[y].replace(/^\s+|\s+$/g, "");    //trim
                   if(evts[y].indexOf(":") >= 0){
                        // oh, if only JS had tuple assignment
                        var funcNameArr = tevt.split(":");
                        tevt = funcNameArr[0].replace(/^\s+|\s+$/g, "");
                        thisFunc = funcNameArr[1].replace(/^\s+|\s+$/g, "");
                   }
                   if(!thisFunc){
                        thisFunc = tevt;
                   }
                  dojo.event.connect(nodes[i], tevt, this, thisFunc );
               }
           }

           this.scanTag( nodes[i] );
       }
    },




Karl Tiedt wrote:
> Robert,
>    I've passed this on to try and find someone familiar with
> Xslt+Dojo that could find you an answer. Just wanted to let you know
> it wasnt being ignored :)
-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    (334) 821-5412
    www.ipov.net



More information about the Dojo-interest mailing list