问题描述
我在使用zTree库时遇到问题.这是我的代码
I got problem with using zTree library. this is my code
<script type="text/javascript" src="<?php echo base_url()?>asset/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>asset/js/jquery.ztree.core-3.5.js"></script>
<SCRIPT type="text/javascript">
<!--
var setting = {
data: {
simpleData: {
enable: true
}
}
};
var zNodes =[
{ id:1, pId:0, name:"Custom Icon 01", open:true, iconOpen:"<?php echo base_url()?>asset/img/diy/1_open.png", iconClose:"<?php echo base_url()?>asset/img/diy/1_close.png"},
{ id:11, pId:1, name:"leaf node 01", icon:"<?php echo base_url()?>asset/img/diy/2.png"},
{ id:12, pId:1, name:"leaf node 02", icon:"<?php echo base_url()?>asset/img/diy/2.png"},
{ id:13, pId:1, name:"leaf node 03", icon:"<?php echo base_url()?>asset/img/diy/2.png"},
{ id:2, pId:0, name:"Custom Icon 02", open:true, iconOpen:"<?php echo base_url()?>asset/img/diy/1_open.png", iconClose:"<?php echo base_url()?>asset/img/diy/1_close.png"},
{ id:21, pId:2, name:"leaf node 01", icon:"<?php echo base_url()?>asset/img/diy/8.png"},
{ id:22, pId:2, name:"leaf node 02", icon:"<?php echo base_url()?>asset/img/diy/8.png"},
{ id:23, pId:2, name:"leaf node 03", icon:"<?php echo base_url()?>asset/img/diy/8.png"}
];
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
//-->
</SCRIPT>
我收到一些类似的错误
请帮助我,如何解决此问题?谢谢
please help me, how can I resolve this problem? thanks
推荐答案
发生这种情况是因为在多个地方都包含了js.我在门户页面中遇到了相同的问题,其中jquery-1.4.4.min.js和jquery.ztree.core-3.5.js包含很多地方.
This happens because of including js at multiple places. I have encountered the same issue in my Portal page where jquery-1.4.4.min.js and jquery.ztree.core-3.5.js were included many places.
我通过从该页面上的所有portlet中删除所有对js的引用并按给定顺序将这些js全局添加到theme/_diff/portal_noraml.vm中来解决了此问题.
I fixed this issue by removing all references to js from all the portlets on that page and added these js globally in theme/_diff/portal_noraml.vm in the given order.
这篇关于未捕获的TypeError:无法读取zTree_v3库上未定义的属性"init"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!