1. 程式人生 > >LayUI最近遇到的問題以及處理

LayUI最近遇到的問題以及處理

做了 order ali ont 我不 pdo end put apply

layui是我最近才接觸的..也是新項目中用到的後臺前端框架..與easyui有些類似..在這段時間的使用中,經常會碰到大大小小的問題..

1.選顯卡切換又是加載數據表格。分頁條不顯示

2.layui.open彈出框中的無法觸發用js.或者jquery寫得觸發事件..

等問題..但是這兩個問題是我遇到過最坑的..

至於解決辦法

1.針對分頁欄無法顯示..只能通過切換表格的時候重新加載數據表格

2.彈出框中的事件..只能使用layui的事件方式觸發..例如我做了個復選款權限樹..

但是卻無法觸發復選款改變事件..或者點擊事件..通過不斷的嘗試..最後用了layui標準的復選款監聽..才能觸發..這浪費了我不少時間..

$(‘#add-btn‘).click(function(){

var index=layer.open({

type: 1

,area: [‘550px‘,‘400px‘]

,title: [‘添加門店‘, ‘font-size:16px;height:40px;line-height:40px;background:#fff;border-top:3px solid #3a90b8;border-bottom:1px solid #e0e0e0‘]

,content: str

,btn: [‘確認‘, ‘取消‘]

,shade: 0.1 //不顯示遮罩

,yes: function(index, layero){

var str="";

$("#tip-organ").html();

$("#hidInfo").html();

var organs=$("input[name=‘fen1‘]");

var inpstr="";

for(var i=0;i<organs.length;i++){

var organ="";

if(organs[i].checked == true){

var title=organs[i].title;

organ=organs[i].value;

var id=‘id‘+organ;

console.log(id);

str+=title;

str+=‘:‘;

inpstr+=‘<input type="hidden" name="organId" id="shopId" value="‘+organ+‘">‘;

var online=$("#"+id+" input[name=‘type1‘]").is(‘:checked‘);

console.log(online);

var offLine=$("#"+id+" input[name=‘type2‘]").is(‘:checked‘);

console.log(offLine);

if(online==true && offLine==true){

inpstr+=‘<input type="hidden" name="kind" id="applykind" value="3">‘

str+=$("#"+id+" .shop-two-unit input:checkbox[name=‘type1‘]:checked").attr("title");

str+=",";

str+=$("#"+id+" input:checkbox[name=‘type2‘]:checked").attr("title");

}else if(offLine==true && online==false){

var title=$("#"+id+" input:checkbox[name=‘type2‘]:checked").attr("title");;

str+=title;

str+=",";

inpstr+=‘<input type="hidden" name="kind" id="applykind" value="2">‘

}else if(online==true && offLine==false){

var title=$("#"+id+" input:checkbox[name=‘type1‘]:checked").attr("title");;

str+=title;

str+=",";

inpstr+=‘<input type="hidden" name="kind" id="applykind" value="1">‘

}else{

layer.msg(‘請選擇門店活動適用範圍!‘);

return false;

}

}

}

$("#tip-organ").html(str);

$("#hidInfo").html(inpstr);

layer.closeAll();

}

,cancel: function(index, layero){

}, success: function(layero, index){

shopstr=loadShopDom();

$(".shop-r").html(shopstr);

var form = layui.form;

form.render(‘checkbox‘);

$("document").on(‘click‘,‘#father‘,function(){

alert("2");

if ($(this).prop("checked") == true) {

$(this).parents("li").eq(0).find("input:checkbox").prop("checked", true);

} else {

$(this).parents("li").eq(0).find("input:checkbox").prop("checked",false);

}

var form = layui.form;

form.render(‘checkbox‘);

});

$(‘#father‘).click(function(){

alert("2");

if ($(this).prop("checked") == true) {

$(this).parents("li").eq(0).find("input:checkbox").prop("checked", true);

} else {

$(this).parents("li").eq(0).find("input:checkbox").prop("checked",false);

}

form.render(‘checkbox‘);

});

form.on(‘checkbox(owner_one)‘, function(data){

if ($(this).prop("checked") ==true) {

$(this).parents("li").parents("li").eq(0).find("input:checkbox.father").prop("checked", true);

} else {

if ($(this).parents("li").parents("li").eq(0).find("input:checkbox:not(.father):checked").length == 0) {

$(this).parents("li").parents("li").eq(0).find("input:checkbox.father").prop("checked",false);

}

}

form.render(‘checkbox‘);

});

form.on(‘checkbox(owner_all)‘, function(data){

var a = data.elem.checked;

if(a == true){

$(this).parents("li").eq(0).find("input:checkbox").prop("checked", true);

form.render(‘checkbox‘);

}else{

$(this).parents("li").eq(0).find("input:checkbox").prop("checked",false);

form.render(‘checkbox‘);

}

});

}

});

});

});

LayUI最近遇到的問題以及處理