开发者

Jquery Dynatree plugin using clicks in id

开发者 https://www.devze.com 2023-03-25 17:03 出处:网络
Using Firebug I have found that the Dynatree plugin changes the following code: <li id=\"id3.1\" class=\"expanded\"&g开发者_如何转开发t;Menu 1

Using Firebug I have found that the Dynatree plugin changes the following code:

<li id="id3.1" class="expanded"&g开发者_如何转开发t;Menu 1
  <ul>
        <li id="id3.1.1">Sub-menu 1</li>
  </ul>
</li>

To this:

<li class="">
   <span class="dynatree-node dynatree-exp-c dynatree-ico-c">
   <span class="dynatree-connector"></span>
   <span class="dynatree-icon"></span>
      <a class="dynatree-title" href="#">Sub-menu 1</a>
   </span>
</li>

So when I try to make a click event on the id="id3.1.1" nothing happens because this id doesn't exist anymore.

I made a search here and found the onActivate option that will make my click happen on the menu:

$("#treeMenu").dynatree({
    onActivate: function(node){
        var menuTitle = node.data.title;
        alert(menuTitle);
    }
});

My question: Is this the only way to do the click event using Dynatree?


Well I think that is the best option, because it uses the API of the plugin, but of course you could still attach an event to the <a> like this:

$('a.dynatree-title').live('click', function(e){
     //here e.target is the link you have clicked
});
0

精彩评论

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