监听表单按钮方式一:
- 注意添加 lay-filter=“editor”
<div class="layui-form-item">
<div class="layui-row">
<div class="layui-col-md12 layui-col-lg12" style="text-align: center">
<a class="layui-btn layui-anim layui-anim-scale layui-btn-radius layui-btn-normal" lay-submit lay-filter="editor">保存</a>
</div>
</div>
</div>
form.on("submit(editor)",function(data){
console.log(data.field);
$.ajax({
url: '[[@{/role/insert}]]',
data: data.field,
dataType:'json',
type: 'get',
success:function(rs){
if(rs.code === 0){
layer.msg(rs.msg,function(){
// 给list里面的div添加了id,然后调用reload刷新函数
parent.reload();
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
parent.layer.close(index);
})
}else{
layer.msg(rs.msg)
}
}
})
})
监听表单按钮方式二:通过onclik=“函数名()”;
window.函数名 = function() {
}