JS动态设置确认弹窗
多次使用确认弹窗
<!--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动态设置确认弹窗的更多相关文章
- js动态设置padding-top遇到的坑
我想通过js动态设置元素padding-top的百分比值:以下几种都是无法设置成功的: // setAttribute设置padding-top并且转换为百分比 imageBox.setAttribu ...
- Dynamic CRM 2013学习笔记(二十八)用JS动态设置字段的change事件、必填、禁用以及可见
我们知道通过界面设置字段的change事件,是否是必填,是否可见非常容易.但有时我们需要动态地根据某些条件来设置,这时有需要通过js来动态地控制了. 下面分别介绍如何用js来动态设置. 一.动态设 ...
- js动态设置窗体位置
1设置登录框的js,动态设置高度等 <script> $(document).ready(function () { $() / + "px"); $("in ...
- js动态设置根元素的rem方案
方案需求: rem 单位在做移动端的h5开发的时候是最经常使用的单位.为解决自适应的问题,我们需要动态的给文档的根节点添加font-size 值. 使用mediaquery 可以解决这个问题,但是每一 ...
- js动态设置输入框字体/颜色
动态设置文本框颜色: 主要是利用javascript中的触发事件onfocus和onblur <script language="javascript" type=" ...
- JS动态设置css的几种方式
1. 直接设置style的属性 某些情况用这个设置 !important值无效 如果属性有'-'号,就写成驼峰的形式(如textAlign) 如果想保留 - 号,就中括号的形式 element. ...
- js 动态设置键值对数组 ,类似于 java 的Map 类型
1.前言 我想设置一个数据 var json = {a1 :1 , a2 :2 , a3 :3 .....} 这样的动态数据 ,怎么写呢? 2.正确写法 var json = []; for ...
- Js动态设置rem来实现移动端字体的自适应
//设置根元素字体 var win = window, doc = document; function setFontSize() { var winWidth = $(window).width( ...
- Js 动态设置DIV日期信息
HTML代码如下: <div id="time"> 2013年12月20日 14:49:02 星期五 </div> JS代码如下: window.onlo ...
随机推荐
- 第三百三十七节,web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS
第三百三十七节,web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS PhantomJS虚拟浏览器 phantomjs 是一个基于js的webkit内核无头浏览器 ...
- e793. 监听JSpinner数据变化
// Create a nummber spinner JSpinner spinner = new JSpinner(); // Add the listener spinner.addChange ...
- jQuery 文件上传插件:uploadify、swfupload
jQuery 文件上传插件: uploadify.swfupload
- Java对象序列化给分布式计算带来的方便
什么时候使用序列化: 一:对象序列化可以实现分布式对象.主要应用例如:RMI要利用对象序列化运行远程主机上的服务,就像在本地机上运行对象时一样.二:对象序列化不仅保留一个对象的数据,而且递归保存对象引 ...
- 正则表达式sed
sed 能实现grep查找的功能,还可以替换指定的字符. 匹配查找文件中root字符(其中的 -n表示段落,p表示打印出来print) [root@localhost sed]# sed -n '/ ...
- hive 添加自增列
比如一个表里只有contact字段 ;
- bootstrapValidator 表单验证
官网下载地址:http://plugins.jquery.com/bootstrapValidator/ html代码 <!DOCTYPE html> <html> <h ...
- KSImageNamed项目图片智能提示
下载地址:https://github.com/ksuther/KSImageNamed-Xcode PS:如果在插件未更新到支持Xcode 6.3.2的情况下,要在Xcode 6.3.2中使用,需要 ...
- 避免使用jQuery的html方法来替换标签,而是使用replaceWith方法
tblCostSplit.html内容: <nobr title="">只想显示里面内容,去掉nobr标签</nobr> <nobr title=&q ...
- 安装oh my zsh和git插件
http://macshuo.com/?p=676 --安装oh my zsh http://www.jianshu.com/p/9189eac3e52d https://github.com/r ...