多次使用確認彈窗

1 <!--START 確認收貨--> 2 <div class="popout-boxbg out" id="delivery_goods"> 3 <div class="popout-box-ios"> 4 <div class="header center font-size-16" name="confirm_dialog_title">隨便編一點 </div> 5 <div class="content c-gray-dark font-size-14" name="confirm_dialog_content">確認收貨后,訂單交易完成。 </div> 6 <div class="action-container"> 7 <button class="js-ok" name="confirm_dialog_confirmbtn">確認收貨</button> 8 <button class="js-cancel" name="confirm_dialog_cancelbtn">取消</button> 9 </div> 10 </div> 11 </div> 12 <!--確認彈窗對象--> 13 <script> 14 var confirmDialogModel = { 15 //傳入主題,內容,確認按鈕字,取消按鈕字,確認按鈕事件,取消事件事件,確認事件參數數組,取消事件參數數組 16 Init: function (title, content, confirmText, cancelText, confirmFunc, cancelFunc, confirmParam, cancelParam) { 17 //設置數據 18 this.InitData(title, content, confirmText, cancelText, confirmFunc, cancelFunc, confirmParam, cancelParam); 19 this.EditModal(); 20 $("#" + this.ID).addClass("in"); 21 }, 22 ID: "delivery_goods", 23 Title: "確認彈窗", 24 Content: "確認后,事件完成", 25 ConfirmButtonFunc: function () { alert("確認點擊") }, 26 ConfirmButtonText: "確認", 27 CancelButtonFunc: function () { $("#" + this.ID).removeClass("in"); }, 28 CancelButtonText: "取消", 29 ConfirmParam: {},//確認傳遞的參數值 30 CancelParam: {},//取消傳遞的參數值 31 InitData: function (title, content, confirmText, cancelText, confirmFunc, cancelFunc, confirmParam, cancelParam) { 32 if (title != undefined) { 33 this.Title = title; 34 } 35 else { 36 this.Title = "確認"; 37 } 38 if (content != undefined) { 39 this.Content = content; 40 } 41 else { 42 this.Content = "確認后,事件完成。"; 43 } 44 if (confirmText != undefined) { 45 this.ConfirmButtonText = confirmText; 46 } 47 else { 48 this.ConfirmButtonText = "確認"; 49 } 50 if (cancelText != undefined && confirmText != "") { 51 this.CancelButtonText = cancelText; 52 } 53 else { 54 this.CancelButtonText = "取消"; 55 } 56 if (confirmFunc != undefined && typeof confirmFunc == "function") { 57 this.ConfirmButtonFunc = confirmFunc; 58 } 59 else { 60 this.ConfirmButtonFunc = function () { 61 alert("確認按鈕點擊"); 62 $("#" + this.ID).removeClass("in"); 63 } 64 } 65 if (cancelFunc != undefined && typeof confirmFunc == "function") { 66 this.CancelButtonFunc = cancelFunc; 67 } 68 else { 69 this.CancelButtonFunc = function () { 70 alert("取消按鈕點擊"); 71 $("#" + this.ID).removeClass("in"); 72 } 73 } 74 if (confirmParam == undefined) { 75 this.ConfirmParam = {}; 76 } 77 else { 78 this.ConfirmParam = confirmParam; 79 } 80 if (cancelParam == undefined) { 81 this.CancelParam = {}; 82 } 83 else { 84 this.CancelParam = cancelParam; 85 } 86 }, 87 EditModal: function () { 88 var obj = $("#" + this.ID); 89 $(obj).find("[name=confirm_dialog_title]").text(this.Title); 90 $(obj).find("[name=confirm_dialog_content]").text(this.Content); 91 $(obj).find("[name=confirm_dialog_confirmbtn]").text(this.ConfirmButtonText); 92 $(obj).find("[name=confirm_dialog_cancelbtn]").text(this.CancelButtonText); 93 $(obj).find("[name=confirm_dialog_confirmbtn]").off("click"); 94 $(obj).find("[name=confirm_dialog_confirmbtn]").on("click", this.ConfirmButtonFunc); 95 $(obj).find("[name=confirm_dialog_cancelbtn]").off("click"); 96 $(obj).find("[name=confirm_dialog_cancelbtn]").on("click", this.CancelButtonFunc); 97 }, 98 CloseModal: function () { 99 $("#" + this.ID).removeClass("in"); 100 } 101 }; 102 </script> 103 <!--START 收貨按鈕點擊--> 104 <script> 105 function receipt(id) { 106 confirmDialogModel.Init("確認收貨", "確認收貨后,訂單交易完成。", "確認收貨", "取消", confirmReceipt, undefined, { "id": id }, {}); 107 } 108 </script> 109 <!--START 確認收貨-->
其中如果想放html類型的內容,如<span style="color:red">主題名</span>,那替換的時候就用$(obj).html("<span style="color:red">主題名</span>")。
主要是嫌多個彈窗,都要加一個html,還不如用一個,反正每次也只允許彈一個。忘記說了,這個需要添加浮層的,就是不允許后面的html點擊。至於樣式,自由發揮吧
<div class="popout-boxbg out" id="delivery_goods"> <div class="popout-box-ios"> <div class="header center font-size-16" name="confirm_dialog_title">隨便編一點 </div> <div class="content c-gray-dark font-size-14" name="confirm_dialog_content">確認收貨后,訂單交易完成。 </div> <div class="action-container"> <button class="js-ok" name="confirm_dialog_confirmbtn">確認收貨</button> <button class="js-cancel" name="confirm_dialog_cancelbtn">取消</button> </div> </div> </div>