父窗体点击按钮打开layer.open(type=2)子窗口1,子窗口1又打开子窗口2,子窗口2调用父窗体方法,父窗体方法执行成功后,调用子窗口1的方法。局部刷新一个div。
主窗口model的方法function modifyLogin(data, index) {
$.ajax({
type: "post",
async: false,
dataType: "json",
data: data.field,
url: "/admin/modifylogin",
success: function (result) {
var state = result.state;
if (state == "success") {
layer.msg(result.content, { time: 1000, anim: -1 }, function () {
layer.close(index);
// 调用子窗口1的方法,局部刷新
});
} else {
layer.msg(result.content);
}
}
});
}子窗口1model的部分方法modify: function (othis) {
var ip = othis.data('ip'),
port = othis.data('port'),
stationName = othis.data('stationname');
layer.open({
type: 2,
area: ['560px', '600px'],
title: '修改资产',
fixed: false,
maxmin: true,
scrollbar: false,
content: '/admin/showlogin?ip=' + ip + '&port=' + port + '&stationname=' + stationName
});
}
// 此为局部刷新方法
function refreshLogin()
{
$('#loginlist').load('/admin/loadlogin?stationname=' + $('input[name=customname]').val(), function () {
$('.layui-btn-dynamic').on('click', function () {
var othis = $(this),
method = othis.data('method');
active[method] ? active[method].call(this, othis) : '';
});
});
}
var showtask = {}
showtask.refreshLogin = refreshLogin;
exports('showtask', showtask);子窗口2model的部分方法form.on('submit(btn_save)', function (data) {
if (isNew) {
parent.addLogin(data, index);
} else {
parent.modifyLogin(data, index);
}
return false;
});