javascript events - dojo eventListener via dojo.connect attach to multiple objects with same id -
so trying attach onclick event set of links same id("linktodisplay") , doesn't seem triggering onclick event code follows:
var handle = []; var link = dojo.query('#linktodisplay a').foreach(function(node, index, array){ handle.push(dojo.connect(node, "onclick", null, function(evt) { console.log("mouseup detected, firring off server request"); dojo.xhrget({url:'default/data/getpagecontent?main=true&pageid='+evt.target.name, load: funccallback, error: funcerror}); } )); });
funcerror , funccallback defined , working (if pass in single object retrieved dojo.getid, otherwise script fails silently).
i putting code inside dojo.addonload code block, , don't see events fired off when click anywhere on page i'm pretty sure not problem attaching event listener wrong piece of dom.
so appears dojo enforces schema id's unique, if dom element has id matches end result query method returns first.
here sample of ended with:
dojo.query(".links a").onclick(function(evt){ dojo.stopevent(evt); var link = evt.target; onsubmit(link) } );
.links specifies class="links", , there sort anchor objects including 'a' after , use convenience function onclick event, grab target , pass onsubmit function (which contains validation , xhr request.).
Comments
Post a Comment