多次使用确认弹窗

 <!--START 确认收货-->
<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>
<!--确认弹窗对象-->
<script>
var confirmDialogModel = {
//传入主题,内容,确认按钮字,取消按钮字,确认按钮事件,取消事件事件,确认事件参数数组,取消事件参数数组
Init: function (title, content, confirmText, cancelText, confirmFunc, cancelFunc, confirmParam, cancelParam) {
//设置数据
this.InitData(title, content, confirmText, cancelText, confirmFunc, cancelFunc, confirmParam, cancelParam);
this.EditModal();
$("#" + this.ID).addClass("in");
},
ID: "delivery_goods",
Title: "确认弹窗",
Content: "确认后,事件完成",
ConfirmButtonFunc: function () { alert("确认点击") },
ConfirmButtonText: "确认",
CancelButtonFunc: function () { $("#" + this.ID).removeClass("in"); },
CancelButtonText: "取消",
ConfirmParam: {},//确认传递的参数值
CancelParam: {},//取消传递的参数值
InitData: function (title, content, confirmText, cancelText, confirmFunc, cancelFunc, confirmParam, cancelParam) {
if (title != undefined) {
this.Title = title;
}
else {
this.Title = "确认";
}
if (content != undefined) {
this.Content = content;
}
else {
this.Content = "确认后,事件完成。";
}
if (confirmText != undefined) {
this.ConfirmButtonText = confirmText;
}
else {
this.ConfirmButtonText = "确认";
}
if (cancelText != undefined && confirmText != "") {
this.CancelButtonText = cancelText;
}
else {
this.CancelButtonText = "取消";
}
if (confirmFunc != undefined && typeof confirmFunc == "function") {
this.ConfirmButtonFunc = confirmFunc;
}
else {
this.ConfirmButtonFunc = function () {
alert("确认按钮点击");
$("#" + this.ID).removeClass("in");
}
}
if (cancelFunc != undefined && typeof confirmFunc == "function") {
this.CancelButtonFunc = cancelFunc;
}
else {
this.CancelButtonFunc = function () {
alert("取消按钮点击");
$("#" + this.ID).removeClass("in");
}
}
if (confirmParam == undefined) {
this.ConfirmParam = {};
}
else {
this.ConfirmParam = confirmParam;
}
if (cancelParam == undefined) {
this.CancelParam = {};
}
else {
this.CancelParam = cancelParam;
}
},
EditModal: function () {
var obj = $("#" + this.ID);
$(obj).find("[name=confirm_dialog_title]").text(this.Title);
$(obj).find("[name=confirm_dialog_content]").text(this.Content);
$(obj).find("[name=confirm_dialog_confirmbtn]").text(this.ConfirmButtonText);
$(obj).find("[name=confirm_dialog_cancelbtn]").text(this.CancelButtonText);
$(obj).find("[name=confirm_dialog_confirmbtn]").off("click");
$(obj).find("[name=confirm_dialog_confirmbtn]").on("click", this.ConfirmButtonFunc);
$(obj).find("[name=confirm_dialog_cancelbtn]").off("click");
$(obj).find("[name=confirm_dialog_cancelbtn]").on("click", this.CancelButtonFunc);
},
CloseModal: function () {
$("#" + this.ID).removeClass("in");
}
};
</script>
<!--START 收货按钮点击-->
<script>
function receipt(id) {
confirmDialogModel.Init("确认收货", "确认收货后,订单交易完成。", "确认收货", "取消", confirmReceipt, undefined, { "id": id }, {});
}
</script>
<!--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>

JS动态设置确认弹窗的更多相关文章

  1. js动态设置padding-top遇到的坑

    我想通过js动态设置元素padding-top的百分比值:以下几种都是无法设置成功的: // setAttribute设置padding-top并且转换为百分比 imageBox.setAttribu ...

  2. Dynamic CRM 2013学习笔记(二十八)用JS动态设置字段的change事件、必填、禁用以及可见

    我们知道通过界面设置字段的change事件,是否是必填,是否可见非常容易.但有时我们需要动态地根据某些条件来设置,这时有需要通过js来动态地控制了. 下面分别介绍如何用js来动态设置.   一.动态设 ...

  3. js动态设置窗体位置

    1设置登录框的js,动态设置高度等 <script> $(document).ready(function () { $() / + "px"); $("in ...

  4. js动态设置根元素的rem方案

    方案需求: rem 单位在做移动端的h5开发的时候是最经常使用的单位.为解决自适应的问题,我们需要动态的给文档的根节点添加font-size 值. 使用mediaquery 可以解决这个问题,但是每一 ...

  5. js动态设置输入框字体/颜色

    动态设置文本框颜色: 主要是利用javascript中的触发事件onfocus和onblur <script language="javascript" type=" ...

  6. JS动态设置css的几种方式

    1. 直接设置style的属性  某些情况用这个设置 !important值无效 如果属性有'-'号,就写成驼峰的形式(如textAlign)  如果想保留 - 号,就中括号的形式  element. ...

  7. js 动态设置键值对数组 ,类似于 java 的Map 类型

    1.前言 我想设置一个数据  var json = {a1 :1  , a2 :2  , a3 :3  .....} 这样的动态数据 ,怎么写呢? 2.正确写法 var json = []; for ...

  8. Js动态设置rem来实现移动端字体的自适应

    //设置根元素字体 var win = window, doc = document; function setFontSize() { var winWidth = $(window).width( ...

  9. Js 动态设置DIV日期信息

    HTML代码如下: <div  id="time"> 2013年12月20日 14:49:02 星期五 </div> JS代码如下: window.onlo ...

随机推荐

  1. unity-------------UI的界面调节

    Rect Transform 我们都知道,Unity3D中所有的GameObject都必须要携带一个Transform组件,且该组件无法移除,那么作为UI显示的GameObject则不是携带Trans ...

  2. Git -- 分支管理简介

    分支就是科幻电影里面的平行宇宙,当你正在电脑前努力学习Git的时候,另一个你正在另一个平行宇宙里努力学习SVN. 如果两个平行宇宙互不干扰,那对现在的你也没啥影响.不过,在某个时间点,两个平行宇宙合并 ...

  3. (实用)Eclipse中使用命令行(运行外部程序)

    备忘 http://www.oschina.net/question/28_46291 另外,在eclipse的console菜单中可以选择“new console view”(新控制台视图),这样就 ...

  4. powerDesigner生成Html及Word

    转载地址:https://blog.csdn.net/zdp072/article/details/51900794 1:点击Reports 2:点击New Reports 3:定义名字,选择简体中文 ...

  5. 轻量实用的PHP分页组件:Paginator

    来源:https://www.helloweba.com/view-blog-453.html demo:https://www.helloweba.com/demo/2017/Paginator/

  6. nginx配置一、二级域名、多域名对应(api接口、前端网站、后台管理网站)

    前提:安装好nginx,如果已经启动nginx,先停止,命令: ./usr/local/nginx/sbin/nginx -s stop 修改nginx配置 vi /usr/local/nginx/c ...

  7. 【WP8】LoopingSelector

    WP8的WindowsPhoneToolkit工具包中有一个 LoopingSelector 可以想选择日期或时间一样进行选择 1.首先当然是引用WindowsPhoneToolkit 在Nuget控 ...

  8. 【Math】矩阵求导

    https://en.wikipedia.org/wiki/Matrix_calculus http://blog.sina.com.cn/s/blog_7959e7ed0100w2b3.html

  9. 通过expect免自动输入密码登陆远程服务器

    通过expect免自动输入密码登陆远程服务器 1.前提必须已经安装expect 2.新建login.sh,文件内容如下 #!/usr/bin/expect -f spawn ssh root@140. ...

  10. 2 go语言的基础

    include 内置关键字 注释方法 代码结构(常量,变量,接口,函数的定义) 导入包以及包别名 可见性规则 小练习 内置关键字(25个均为小写) break case chan const cont ...