关于layui标签切换表单验证提交问题

2017-12-29 16:20:43 / 4213 / 默认分类
//切换状态function toggle(layid,html,$,ids){
    for (i=0;i<ids.length;i++){
        if(ids[i]==layid){
	       $('#'+layid).html(html);
	    }
    }}layui.use(['element','jquery','form'], function () {
	var element = layui.element;
	var $       = layui.jquery;
	var form = layui.form;
	window.html = new Array();
    var ids =new Array("info","userpwd","avatar","account");	
    for (i=0;i<ids.length;i++){
        eval("window.html['"+ids[i]+"']=$('#"+ids[i]+"').html();");
		if(i>0){
		   $('#'+ids[i]).html('');
		}
    }
    element.on('tab(users)', function(){
        var layid = this.getAttribute('lay-id');//获取id;
        toggle(layid,html[layid],$,ids);
		form.render();//重新渲染表单状态
		
    });});

以上为主要实现代码,其实就是读取一个lay-id里的内容,然后在切换的时候,把其它的layid内容设成空,这样就没法冲突了

gravatar头像