您的位置:首页 > Web前端 > JavaScript

jstree 点箭头有效但点后面item无效的bug

2011-10-26 22:37 155 查看
比如现在有html(django template)如下:
<li class="jstree-closed">
<ins class="jstree-icon"> </ins>
<a href="#" name="template_category_item" value="{{key}}"><ins class="jstree-icon"> </ins>{{key}}</a>
<ul>
{% for template in value %}
<li class="jstree-last jstree-leaf">
<ins class="jstree-icon"> </ins>
<a href="#" name="template_list_item" value="{{template.pk}}"><ins class="jstree-icon"> </ins>{{template.module}}</a>
</li>
{% endfor %}
</ul>
</li>


为了修复这个bug,只要给template_category_item添加一个事件响应即可,代码如下:

$("a[name=template_category_item]").live("click", function(e){
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
$(this).prev()[0].dispatchEvent(evt);
return false;
});





                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐