开发者

dojo.connect VS <script type="dojo/connect"> (DojoML)

First of all I want to say Im new in the DOJO world and probably for some persons this question is stupid :). But also somebody says that there is no stupid questions.

Here is my problem:

I got a quick question related to 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜