使用Layer彈出一個頁面


 

使用Get方式獲取到請求頁面的Html,然后作為Content使用Layer彈出來

$.get('@Url.Action("AddressAdd", "Customer")', {}, function (result) {
  if (result.Flag == 0) {
    ZTLayer.showTips(result.Message, 2);
    return;
}
ZTLayer.openWindow(result, '@T("Account.CustomerAddresses.AddNew")', 600);

 

 

 

openWindow: function (content, title, width, height) {
  width = width || 500;
  height = height || 500;


  var offset = ((window.screen.height - height) * 0.3) + 'px';

  return layer.open({
    title: title
    , content: content
    , type: 1
    , offset: offset //具體配置參考:http://www.layui.com/doc/modules/layer.html#offset
    , shade: 0.5 // 遮罩層透明度
    , resize: false
    , area: [width + 'px', height + 'px']
    , skin: 'layui-layer-rim'
  });
},

 

 

var surefun = function () {
$.post('@Url.Action("CancelOrder")', postData, function (data) {
  if (data.flag) {
    location.reload();
  } else {
    ZTLayer.showTips(data.msg);
  }
 })
};
ZTLayer.confirm('@T("Admin.Common.AreYouSure")', '', '@T("Common.Yes")', surefun, '@T("Common.No")')

 

 

//與JS confirm相似
confirm: function (content, title, sureText, sureFunction, closeText, closeFunction) {
  title = title || "";

  layer.confirm(
    content, { title: title, icon: 3, btn: [sureText, closeText], resize: false },
    function (index) {//確定回調
    if (sureFunction) {
      sureFunction();
    }
    layer.close(index);
}, function (index) {//cancel回調
  if (closeFunction) {
    closeFunction();
  }
  layer.close(index);
});
},

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM