本文主要介紹了jQuery、layer實現彈出層的打開、關閉功能,需要的朋友可以參考下,希望能幫助到大家。
打開彈出層:
在list頁面帶入layer.js
在list頁面點擊時,彈出form彈出層,list.js:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$( ".add_category,.update" ).click( function (){
var doMain = $( '.domain_name' ).val();
layer.open({
shade: [0.5, '#000' , false ],
type: 2,
area: [ '900px' , '530px' ],
fix: false ,
maxmin: true ,
title: [ '添加或修改用戶類型' , false ],
content: doMain+ "/Stat/QueryUserCategoryForm.action?adminUserCategory.id=" +$( this ).val()
});
});
|
在點擊form彈出層的“保存”按鈕時,如果保存數據成功,則關閉彈出層,並且刷新list頁面:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<span style= "color:#000099;" >submitHandler: function (form){
$.post(
$( '.domain_name' ).val()+ "/Stat/AddOrUpdateUserCategory.action" ,
$(form).serialize(),
function (data){
var result = eval( "(" +data+ ")" );
if (!result.status){
alert(result.message);
} else {
parent.window.location.href=$( '.domain_name' ).val()+ "/Stat/QueryUserCategoryListStat.action" ;
</span><span style= "color:#ff6666;" > var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index); </span><span style= "color:#000099;" >
}
}
);
} </span>
|