在layer中,我們要先獲取窗口的索引,然后再進行操作。
var index = parent.layer.getFrameIndex(window.name); //獲取窗口索引
$("#update_id").click(function() {
parent.$('#father_id').html(autoSelectName);//對父頁面的元件操作,給id為father_id進行賦值。
window.parent.location.reload(); //刷新父頁面
parent.layer.close(index);
});
openUser是一個js方法,selectId,selectName是傳的參數,里面調用layer的open方法,area是彈出框的大小,content是請求頁面路徑。
還要導入layer的js包,在layer的官網上可以下載,加載layer.js就行,注意,這個好像要求jquery的版本是1.8以上才行。
function openUser(selectId,selectName){ layer.open({ type: 2, title: '選擇關聯人', maxmin: true, area: ['1000px', '600px'], content: '${base}/user/listLayout?selectId='+selectId+'&selectName='+selectName, scrollbar: false, end: function(){ } }); }
在layer的官網有很全的例子供大家學習,我覺得這個功能比較強大,當然如果要弄彈出層,也可以采用bootsrap的靜態框。
layer的官網:http://layer.layui.com/