jquery mobile 实现自定义confirm确认框效果
类似删除的效果,在执行之前,一般需要添加确认对话框,点确认的话执行,取消按钮就不执行,传统的js
if(confirm('确定删除吗?'))
{
//执行代码
}
这种效果比较丑,使用jquery mobile优化一下
需要引用的文件:
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<link href="~/Scripts/Mobile/jquery.mobile-1.4.0.min.css" rel="stylesheet" />
<script src="~/Scripts/Mobile/jquery.mobile-1.4.0.min.js"></script>
效果如下:

function UpdateStatus() {
var popupDialogId = 'popupDialog';
$('<div data-role="popup" id="' + popupDialogId + '" data-confirmed="no" data-transition="pop" data-overlay-theme="b" data-theme="b" data-dismissible="false" style="min-width:216px;max-width:500px;"> \
\
<div role="main" class="ui-content">\
<h3 class="ui-title" style="color:#fff; text-align:center;margin-bottom:15px">确认关闭任务吗?</h3>\
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b optionConfirm" data-rel="back" style="background: #1784fd;width: 33%;border-radius: 5px;height: 30px;line-height: 30px;padding: 0;font-size: .9em;margin: 0 0 0 12%;font-weight: 100;">确定</a>\
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b optionCancel" data-rel="back" data-transition="flow" style="background: #DBDBDB;width: 33%;border-radius: 5px;height: 30px;line-height: 30px;padding: 0;font-size: .9em;margin: 0 0 0 5%;font-weight: 100;color: #333;text-shadow: none;">取消</a>\
</div>\
</div>')
.appendTo($.mobile.pageContainer);
var popupDialogObj = $('#' + popupDialogId);
popupDialogObj.trigger('create');
popupDialogObj.popup({
afterclose: function (event, ui) {
popupDialogObj.find(".optionConfirm").first().off('click');
var isConfirmed = popupDialogObj.attr('data-confirmed') === 'yes' ? true : false;
$(event.target).remove();
if (isConfirmed) {
//这里执行确认需要执行的代码
}
}
});
popupDialogObj.popup('open');
popupDialogObj.find(".optionConfirm").first().on('click', function () {
popupDialogObj.attr('data-confirmed', 'yes');
});
}
分享两个获取汽车品牌数据的地址:
XCAR的
http://html.xcar.com.cn/newcar/pub_js/car_arr_newcar_2009_ps.js
AUTOHOME的
http://www.autohome.com.cn/ashx/AjaxIndexCarFind.ashx?type=1
或者
http://www.autohome.com.cn/ashx/AjaxIndexCarFind.ashx?type=11
获取品牌列表,然后
http://www.autohome.com.cn//ashx/AjaxIndexCarFind.ashx?type=3&value=3
获取车型列表(例子中的value=3对应丰田)。
具体的还可以查在售、停售、即将上市等,可以去AUTOHOME看源码。
jquery mobile 实现自定义confirm确认框效果的更多相关文章
- Vue使用Promise自定义confirm确认框组件
使用Promise模拟浏览器确认框,可自定义标题,内容,按钮文字和类型 参数名 类型 说明 title String 标题 content String 内容 yesBtnText String 确认 ...
- JQuery Mobile - 动态修改select选择框的选中项
<label for="day">选择天</label> <select name="day" id="day" ...
- jquery实现模拟select下拉框效果
<IGNORE_JS_OP style="WORD-WRAP: break-word"> <!DOCTYPE html PUBLIC "-//W3C// ...
- js确认框confirm()用法实例详解
先为大家介绍javascript确认框的三种使用方法,具体内容如下 第一种方法:挺好用的,确认以后才能打开下载地址页面.原理也比较清晰.主要用于删除单条信息确认. ? 1 2 3 4 5 6 7 8 ...
- 自定义jQuery Mobile工具栏按钮
自定义jQuery Mobile工具栏按钮 1.实现效果
- Jquery Mobile设计Android通讯录第二章
本文是jQuery Mobile设计Android通讯录系统教程的第二篇,在上一篇教程中(http://publish.itpub.net/a2011/0517/1191/000001191561.s ...
- react-native自定义Modal模态框|仿ios、微信弹窗RN版
前序 纵观每个优质项目,无论web端还是native原生应用开发,弹窗都是不可忽视的一环,能很大程度上直接决定用户体验.如:微信.支付宝.ios都有很成熟的一套弹窗UI展示场景. 最近一直沉迷在rea ...
- 如何修改Jquery Mobile 设置默认选项
以下的默认配置可以通过$.mobile对象重新配置自定义命名空间s (字符, 默认: ""): 在jQuery Mobile中,甚至可以自定义象HTML5中的data-attrib ...
- JQ三种提示框:提示信息框、确认框、输入文本框
浏览器的三种提示框: alert()提示信息框 confirm()提示确认框 prompt()提示输入文本框 1.alert()提示信息框 效果: 实现代码: <script> alert ...
随机推荐
- $().each 和表单事件的坑
在用each循环时 1.想结束循环 return false 2.想跳过某循环 return 3.想跳出function 不行,请切换成其他循环如 for 使用form表单事件 1.必须要有submi ...
- webstorm增加less开发插件
原文 http://a317222029201405212739.iteye.com/blog/2174140 引自 http://www.tuicool.com/articles/aeye6rY ...
- Asp.Net Core 项目从 1.0.1 升级到 1.1.0 的小补丁
还有 25 天就要交期末作业了,虽然还有好些功能没完成,但是前端同学还是建议先放到云上跑一跑,于是我轻车熟路的用 VS 2017 搞起了 FTP 发布,然而,发布失败了,错误信息如下: "D ...
- 函数对象(仿函数 functor)
简单地说,函数对象就是一个重载了()运算符的类实例,它可以像一个函数一样使用. #include <iostream> using namespace std; class Add { p ...
- pysvn安装及常用方法
centos 6.5,svn 1.6.11,pysvn 1.7.6,文章内容来自官网文档:http://pysvn.tigris.org/docs/pysvn_prog_guide.html 直接用y ...
- 使用MegaCli工具查看Raid磁盘阵列状态
转载自:http://home.51.com/chenjianghui1987/diary/item/10051836.html 文章本身我不做过多修改了,在这里我就把自己在安装时候碰到的难点跟大家提 ...
- android dialog
/** * @Title MenuTest.java * @package com.example.standardview * @since * @version 1.0.0 * @author V ...
- 8.mvc core上传文件
以下方法均是个人,仅供参考 public interface IFileHelper { /// <summary> /// 保存文件 (返回 Test.jpg) 出错就返回 error| ...
- JavaScript中数组迭代方法(jquery)
var arr = [1,2,4,5,6]; //1.forEach(让数组中的每一项做一件事)arr.forEach(function(item,index){ console.log(ite ...
- TryUpdateModel
MSDN参考 https://msdn.microsoft.com/zh-cn/library/system.web.mvc.controller.tryupdatemodel.aspx 相关博文 h ...