1)在彈出層的操作:
//這裏是提交操作_彈出層
$.ajax({
url:'/conpany.php?g=Conpany&c=Device&a=deviceCz',
type:'get',
data:data.field,
dataType:"json",
success:function(data){
if(data.code == '200'){
alert("提交成功!");
//當你在iframe頁面關閉自身時
var index = parent.layer.getFrameIndex(window.name); //先得到當前iframe層的索引
parent.layer.close(index);
}
else{
layer.alert(data.msg);
}
},
error:function(e){
layer.alert("提交失敗!")
}
});
2)在父類的操作:
$(".addDevice").click(function(){
layer.open({
type: 2,
offset: '15%',
area: ['500px', '800px'],
title: ['添加設備'],
//btn:['提交','取消'],
content:['/conpany.php?g=Conpany&c=Device&a=add_device', 'no'] //這裏content是一個普通的String
,
end: function () {
window.location.reload(); //這裏是刷新的關鍵,當出現層銷燬時就會觸發這個事件
}
});
});
總結:
主要使用的是:
1)//當你在iframe頁面關閉自身時
var index = parent.layer.getFrameIndex(window.name); //先得到當前iframe層的索引
parent.layer.close(index);
備註:這裏的window.name就是這個寫法,不是指的父類中的某個id或者field
2)在父類中主要使用的是end事件_end負責刷新
end: function () {
window.location.reload();
}