treeview的异步加载

阅读更多
treeview的动态加载代码:
  • New Sublist
    • Item1
    • Item2
    • 分类名称
    • ……
     
    ps:treeview本身的动态添加就无法cookie :)
    treeview主要修改的不分:
    1,jquery.treeview.js中添加的部分
    		prepareBranchesForAjax: function(settings) {
    			if (!settings.prerendered) {
    				// mark last tree items
    			
    				
    				//this.children("ul").find("li:last").addClass(CLASSES.last);
    				this.find("li:last").addClass(CLASSES.last);
    
    				// collapse whole tree, or only those marked as closed, anyway except those marked as open
    				//this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
    			}
    			// return all items with sublists
    			return this.filter(":has(>ul)");
    		},
    		prepareBranchesForDF: function(settings) {
    			if (!settings.prerendered) {
    				
    				// mark last tree items
    				//this.filter(":last-child:not(ul)").addClass(CLASSES.last);
    				//this.filter(":last-child:has(ul)").addClass(CLASSES.last);
    				// collapse whole tree, or only those marked as closed, anyway except those marked as open
    				this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
    			}
    			// return all items with sublists
    			return this.filter(":has(>ul)");
    		},
      
    2,query.treeview.edit.js修改的部分
    return proxied.apply(this, arguments).bind("add", function(event, settings) {
    			var branches = settings.add;
    			var self = settings.self;
    			$(branches).prev()
    				.removeClass(CLASSES.last)
    				.removeClass(CLASSES.lastCollapsable)
    				.removeClass(CLASSES.lastExpandable)
    			.find(">.hitarea")
    				.removeClass(CLASSES.lastCollapsableHitarea)
    				.removeClass(CLASSES.lastExpandableHitarea);
    
    			/*异步加载的形成树的主要部分*/
    			$(self).prepareBranchesForDF(settings).applyClasses(settings, $(this).data("toggler"));
    			//$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, $(this).data("toggler"));
    			
    			$(self).prepareBranchesForAjax(settings);
    		}).bind("remove", function(event, branches) {
     
    页面部分:(在这里我没有做分离,全部堆在了页面中)
    <%@ page language="java" pageEncoding="utf-8"%>
    
    
    
    	
    	supplierSortAdd
    	
    	
    	
    	
    	
    	
    	
    	
    
    

    供应商分类

     

     

        

     

    有待改进的部分:

     1,接点展开折叠的cookie缓冲问题,(通过修改treeview的js代码)

     

    • treeview.rar (123.7 KB)
    • 描述: 内部有修改
    • 下载次数: 58

    你可能感兴趣的:(treeview,json,cookie)