easyui的accordion为动态生成,accordion的onSelect方法中又动态生成tree,为什么要第二次选择accordion,tree才生成出来...
作者:互联网
原文链接:https://my.oschina.net/myfirtyou/blog/624320
JS结构
<div id="menu">
</div>
HTML结构
JS结构
1 <script type="text/javascript">
2 $.ajax({
3 url:Thinkphp['MODULE'] + '/Index/getTree',
4 type:'post',
5 success:function(data){
6 $.each(data,function(i,n){
7 $('#menu').accordion('add',{
8 title: n.text,
9 selected: false,
10 content:'<div style="padding:0 0 0 10px;"><ul name="'+n.text+'"></ul></div>',
11 });
12 });
13 },
14 });
15 $('#menu').accordion({
16 fit:true,
17 border:false,
18 onSelect:function(title,index){
19 $("ul[name='"+title+"']").tree({
20 lines:true,
21 url: Thinkphp['MODULE'] + '/Index/getTree/Name/'+encodeURI(title),
22 });
23 console.info(title)
24 },
25 });
26 </script>
一直没找到问题 不知道是什么问题 还希望高手们帮忙解决
转载于:https://my.oschina.net/myfirtyou/blog/624320
标签:function,Index,false,title,accordion,tree,生成 来源: https://blog.csdn.net/chouhequ9493/article/details/100808456