如何在dynaTree jQuery插件中点击超链接? [英] How to make hyperlinks in dynaTree jQuery plugin clickable?

查看:81
本文介绍了如何在dynaTree jQuery插件中点击超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用dynaTree jQuery插件来渲染树。

I am currently using dynaTree jQuery plugin to render a tree.

<div id="tree" style="height:100px;">

<ul class="expanded">

    <li class="expanded" id="shtml_1" >
        <a class="ajaxify" href="jsTree.html" >Root node 1</a>
        <ul>
            <li id="shtml_2">
                <a href="#">Child node 1</a>
                <ul>
                <li id="a"><a href="#">Child node 1-1</a></li>
                <li id="x"><a href="b">Child node 1-2</a></li>
                </ul>
            </li>               
            <li id="c"><a href="#">Child node 2</a></li>
        </ul>
    </li>
    <li id="shtml_4">
        <a href="#">Root node 2</a>
    </li>
</ul>

Javascript -

Javascript -

  $('.ajaxify').ajaxify({
  target: '#container'
  });

    $(function(){
    $("#tree").dynatree({
      title: "Sample Theming",
      // Image folder used for data.icon attribute.
      imagePath: "skin-custom/",
      onSelect: function(node) {
        alert ("You selected " + node);
      }
    });
  });

现在我想


  • 使用jQuery Ajaxify插件(http://max.jsrhost.com/ajaxify/demo.php),这样当用户点击任何节点时,就会调用ajax调用并将结果加载到div中。


  • 绑定锚标签使用jquery以便我可以onclick ajax请求。

现在每当我使用dynaTree时它会覆盖默认行为并阻止锚标记来自点击即可。关于如何做到这一点的任何想法?

Now whenever i use dynaTree it overrides the default behavior and prevents the anchor tag from being click able. Any thoughts on how this can be done?

推荐答案

Dynatree默认删除< a> 标签,因此可以更容易地实现onActivate处理程序:

Dynatree will by default remove the <a> tags, so it is possbly easier to implement the onActivate handler:

onActivate: function(node) { 
    if( node.data.href ){
        // use href and target attributes:
        window.location.href = node.data.href; 
//      window.open(node.data.href, node.data.target);
//      $("#div").load(node.data.href);
    }
}

从版本1.1.2开始,Dynatree将使用<直接来自< a> 标记的code> href 和目标属性:

Starting with release 1.1.2, Dynatree will use href and target attributes directly from the <a> tag:

<li id="x"><a href="b">Child node 1-2</a></li>

在旧版本中你必须像这样设置href:

In older versions you have to set href like so:

<li id="x" data="href: 'b'"><a href="b">Child node 1-2</a></li>

这篇关于如何在dynaTree jQuery插件中点击超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆