我这里的功能是弹出 右侧搜索 的页面:

top.layui.admin.popupRight({
              id: 'LAY_business_PopupLayer'
              ,area: '350px'
              ,success: function(layero,index){
                  var sexArr = top.layui.dict.options("sex");
                  var statusArr = top.layui.dict.options("status");
                  top.layui.view(this.id).render('business/businessUserSearch',$.extend(search_field,{
                      sexArr:sexArr,
                      statusArr:statusArr
})).done(
                      function () {
                          top.layui.form.render();
                      }
                  );
              }
          });

重点是: top.layui.admin.popupRight
而不是:admin.popupRight
同时:PopupLayer 的内容是模板页面,打开代码是:

top.layui.view(this.id).render('business/businessUserSearch');

若有第二个参数,则为传到 businessUserSearch.html模板页的参数。

这里,business/businessUserSearch, 相对目录默认是: /layuiadmin/tpl/ , 且页面默认为html

businessUserSearch.html 代码为:


{{d.params.name}} 是父页面传过来的参数。

父页面监听按钮事件:

top.layui.form.on('submit(businessUser-list-search)', function(data){
    var field = data.field;
    table.reload('businessUserListTable', {
        where: field
    });
    search_field = field;
    top.layui.layer.close(top.layui.admin.popup.index);
});
top.layui.form.on('submit(businessUser-list-refresh)', function(data){
    top.layui.$(':input').not(':button, :submit, :reset').val('').removeAttr('selected').removeAttr('checked')
    search_field = {};
    top.layui.form.render();
    table.reload('businessUserListTable', {
        where: null
    });
});

页面重新渲染、关闭页面、监听事件, 都要 加 :top.layui.