开发者

Failure to trap dijit.Tree "onclick"

开发者 https://www.devze.com 2023-02-28 23:42 出处:网络
I\'ve read开发者_如何转开发 several examples of handling onClick for dijit.Tree.. in particular this one seems to tell me all I need:dojo how to override dijit class method

I've read开发者_如何转开发 several examples of handling onClick for dijit.Tree.. in particular this one seems to tell me all I need: dojo how to override dijit class method

However, for some reason my handler gets called when my page first loads, and never when I click on a tree node?

Here's the code:

<div dojoType="dijit.layout.ContentPane" title="Published Blueprints" minSize="20" style="width: 300px;" id="leftAccordion" region="leading" splitter="true">
   <div id="blueprintTree" dojoType="dijit.Tree" store="" query="" label="Blueprints" openOnClick="false">
   </div>
</div>

...and I then do this...

dojo.ready(function() {
   var tree = dijit.byId("blueprintTree");
   tree.connect(tree, "onClick", function(item) {
       // my code here...
   });
});

... the "my code here" part gets invoked when I start (in debug) my jsp, but never when i lock around on nodes...

Obviously I'm missing something simple?

Regards Brian


Is it required to put the connect inside the dojo.ready()? Maybe that is why it is called on startup?

Looking at the dijit.Tree source, I saw that the onClick had two args This is what I used in my case to successfully capture onClicks:

In the Tree constructor add openOnClick: false:

var tree = new dijit.Tree( {
        model: myModel,
        openOnClick: false,
                    etc...

Then in the same function where I create the tree using the programmatic approach

dojo.connect( tree,"onClick", function(/*dojo.data*/ item, /*TreeNode*/ nodeWidget){
    //my code
});
0

精彩评论

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