Reputation:

Dijit Tree and postCreate event (dojo 1.3)

I have managed to write a function that focusses a given node. Now I want to call it after tree creation. Since I construct the tree with php an send it via AJAX, I want to send the node to focus with the tree. Therefore I found this solution:

<script type="dojo/connect" event="postCreate">focusTreeNode("'.$this->focusitem . '");</script>

This doesnt fire the event. But if I use dojo/method instead, it gets fired but the tree is no longer drawn. I found out that dojo/method replaces the hook and dojo/connect hooks into the chain. I am really confused now and help would be very appreciated since I am stuck in a project with high time pressure.

Thanks! Micha

Upvotes: 0

Views: 1259

Answers (2)

Curtis Yallop
Curtis Yallop

Reputation: 7309

I find postCreate does not fire for dojo/connect for some reason as you have found (and for dojo/method does). "startup" does work using dojo/connect however.

<script type="dojo/connect" data-dojo-event="startup">
    console.log("I will execute on startup");
</script>

Upvotes: 0

Bill Keese
Bill Keese

Reputation: 1931

I suspect your postCreate() code is firing but it's happening before your TreeNode's are created.

If you can upgrade to Dojo 1.4 then there's an onLoad event that you can connect to.

Upvotes: 1

Related Questions