如何在dynaTree jQuery插件中点击超链接?
我目前正在使用dynaTree jQuery插件来渲染树。
Javascript –
$('.ajaxify').ajaxify({ target: '#container' }); $(function(){ $("#tree").dynatree({ title: "Sample Theming", // Image folder used for data.icon attrihttps://stackoverflow.com/questions/6070484/how-to-make-hyperlinks-in-dynatree-jquery-plugin-clickable/bute. 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时它会覆盖默认行为并阻止锚标记被点击。 有关如何做到这一点的任何想法?
Dynatree默认会删除
标签,因此实现onActivate处理程序可能更容易:
onActivate: function(node) { if( node.data.href ){ // use href and target attrihttps://stackoverflow.com/questions/6070484/how-to-make-hyperlinks-in-dynatree-jquery-plugin-clickable/butes: window.location.href = node.data.href; // window.open(node.data.href, node.data.target); // $("#div").load(node.data.href); } }
从1.1.2版开始,Dynatree将直接使用
标签中的href
和target
属性:
Child node 1-2
在旧版本中,您必须像这样设置href:
Child node 1-2