Ayyoudy
Ayyoudy

Reputation: 3721

Dojo contentpane/tab parsing issue

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

Upvotes: 2

Views: 1373

Answers (1)

Gustavo Giráldez
Gustavo Giráldez

Reputation: 2690

this in that context is probably the window object, since you're not specifically setting the scope in your connect (from the code you posted I assume myFunction() is a free function, not a method.

You need to pass dojo.parser.parse a DOM node. Assuming tab is a widget, you can use dojo.parser.parse(tab.domNode) if the function is defined in the context of availability of tab. If this is scoped to the tab widget, then you can use dojo.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 How this works section from the Javascript garden.

Upvotes: 2

Related Questions