layuiAdmin 局部刷新 模板

项目中需要使用到layui局部刷新模板,而layui文档上却没有写出来方法,自己看了下源码 ,才知道怎么用,贴出来和大家一起分享

	
    

    
    
    layui.view('TPL_layout').refresh();
    from.render();
    

    

	//局部刷新模板
	Class.prototype.refresh = function(callback) {
		var that = this,
			next = that.container.next(),
			templateid = next.attr('lay-templateid');
        
		if(that.id != templateid) return that;

		that.parse(that.container, 'refresh', function() {
			that.container.siblings('[lay-templateid="' + that.id + '"]:last').remove();
			typeof callback === 'function' && callback();
		});

		return that;
	};

 

你可能感兴趣的:(layuiAdmin 局部刷新 模板)