dojo.connect VS <script type="dojo/connect"> (DojoML)
<script type="dojo/connect">
to be more exact).
In an example here: http://dojotoolkit.org/reference-guide/dijit/Tree.html
we got somethin like this :
<script type="dojo/connect">
var menu = dijit.byId("tree_menu");
menu.bindDomNode(this.domNode);
dojo.connect(menu, "_openMyself", thi开发者_Go百科s, function(e) {
var tn = dijit.getEnclosingWidget(e.target);
menu.getChildren().forEach(function(i) {
i.attr('disabled', !tn.item.children);
});
});
</script>
Now I would like to translate it to "traditional" script. As I read here : http://dojocampus.org/content/2008/08/09/dojoml-the-best-thing-since-sliced-bread/
such DojoML notation can be translated into :
dojo.connect(oMyTree, 'postCreate', null, function(){});
My question is if this is the right "translation" because it simply doesnt work. My goal is to attach a simple right click menu to every MyTree's node.
I have read some where i like this. This kind of scripts will run once the widget enclosing them is instantiated. Basically will append a extra handler to postCreate. But if you do you are erasing the default postCreate and running your postcreate handler.
精彩评论