I am having issues parsing HTML markup into Dojo widgets. Here is what I am doing:
var tab = new dijit.layout.ContentPane({
title: "xyz",
parseOnLoad: false, //I am doing this intentionally
href: "some-relative-url"
});
tabPane.addChild(tab);
now, if I test this with parseOnLoad = true, I get my widgets loaded nicely. However, I am trying to process the HTML before it is turned into widgets. So I delayed the parsing by adding the parseOnLoad: false option. I binded a function to be called when my tab is loaded (i.e. the Ajax call is complete), like such:
dojo.connect (tab, "onDownloadEnd", myFunction);
function myFunction() {
//manipulate the HTML code via this.content
dojo.parser.parse(this); //this doesn't do anything. I tried many variations!
}
So what happens when I do that is that I end up with the tab loaded but no widgets, just standard HTML controls. So why isn’t the parser being triggered in this scenario and what can I do to make it work on my manipulated HTML?
Thanks
thisin that context is probably thewindowobject, since you’re not specifically setting the scope in yourconnect(from the code you posted I assumemyFunction()is a free function, not a method.You need to pass
dojo.parser.parsea DOM node. Assumingtabis a widget, you can usedojo.parser.parse(tab.domNode)if the function is defined in the context of availability oftab. Ifthisis scoped to the tab widget, then you can usedojo.parser.parse(this.domNode)as you say in your comment.You can force the scope with the almighty powerful
dojo.hitch🙂 Read the documentation here and I recommend the Howthisworks section from the Javascript garden.