js-jquery-从SweetAlert到SweetAlert2
原文地址:https://github.com/limonte/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2
1. IE support
默认不制止IE,如果想支持IE11
<script src="bower_components/es6-promise/promise.auto.min.js"></script>
2. Promise instead of callback function
SweetAlert:
swal(
{title: 'Are you sure?', showCancelButton: true},
function(isConfirm) {
if (isConfirm) {
// handle confirm
} else {
// handle all other cases
}
}
);
SweetAlert2:
swal({title: 'Are you sure?', showCancelButton: true}).then(
function(result) {
// handle Confirm button click
// result is an optional parameter, needed for modals with input
}, function(dismiss) {
// dismiss can be 'cancel', 'overlay', 'esc' or 'timer'
}
);
3. Modal with input field
SweetAlert:
swal({
...
type: 'input'
...
}, function(inputValue) {
...
})
SweetAlert2:
swal({
...
input: 'text' // can be also 'email', 'password', 'select', 'radio', 'checkbox', 'textarea', 'file'
...
}).then(function(inputValue) {
...
})
4. Custom HTML in the title and description
SweetAlert:
swal({
title: '<span class="title">Title</span>',
text: '<span class="text">HTML description</span>',
html: true
})
SweetAlert2:
swal({
title: '<span class="title">Title</span>',
html: '<span class="text">HTML description</span>'
})
5. closeOnConfirm and closeOnCancel parameters replaced with preConfirm
SweetAlert:
swal({
{... closeOnConfirm: false},
function() {
// perform AJAX request
}
});
SweetAlert2:
swal({
...
showLoaderOnConfirm: true,
preConfirm: function() {
return new Promise(function(resolve) {
setTimeout(function() {
resolve();
}, 2000);
});
}
}).then(function() {
swal('Ajax request finished!');
});
6. Reversed buttons order
If you want to keep the buttons order like it was in the original SweetAlert plugin (Confirm button on the right side) set the reverseButtons parameter to true:
swal.setDefaults({
reverseButtons: true
})
js-jquery-从SweetAlert到SweetAlert2的更多相关文章
- js插件---弹出层sweetalert2(总结)
js插件---弹出层sweetalert2(总结) 一.总结 一句话总结: sweetalert2的效果非常好,效果比较Q萌,移动端适配也比较好,感觉比layer.js效果好点 1.SweetAler ...
- js,jquery,css,html5特效
包含js,jquery,css,html5特效,源代码 本文地址:http://www.cnblogs.com/roucheng/p/texiao.html 2017新年快乐特效 jQuery最新最全 ...
- Js/Jquery获取iframe中的元素
转载: Js/Jquery获取iframe中的元素 - - ITeye技术网站http://java-my-life.iteye.com/blog/1275205 在web开发中,经常会用到ifram ...
- js/jquery/html前端开发常用到代码片段
1.IE条件注释 条件注释简介 IE中的条件注释(Conditional comments)对IE的版本和IE非IE有优秀的区分能力,是WEB设计中常用的hack方法.条件注释只能用于IE5以上,IE ...
- js jquery 页面加载初始化方法
js jquery 页面加载初始化方法 一.js页面加载初始化方法 // 1.在body里面写初始化方法. <body onload='init()'> </body> < ...
- js jquery 选择器总结
js jquery 选择器总结 一.原始JS选择器. id选择器:document.getElementById("test"); name选择器:document.getElem ...
- [JS]jQuery,javascript获得网页的高度和宽度
[JS]jQuery,javascript获得网页的高度和宽度网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeigh ...
- spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js...
问题:spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js... web.x ...
- js jquery中 的数据类型
任何一门语言, buguan 是动态的, 还是像C语言的, 都有严格的 类型 "概念的", 这个是由于 编译器和解释器要求的, 需要的. 所以在是使用像 js, jquey ,ph ...
- paip.提升效率--数据绑定到table原理和流程Angular js jquery实现
paip.提升效率--数据绑定到table原理和流程Angular js jquery实现 html #--keyword 1 #---原理和流程 1 #----jq实现的代码 1 #-----An ...
随机推荐
- 【MongoDB】数组长度查询
db.groupedInfo.count({'surveyInfo.surveyAndUserID.0':{$exists:1}})
- SVN目录权限配置
1.如果要使用SVN,需要有一个项目的保存目录,例如把该目录设为“C:\MyPro”文件夹 2.把该目录发布为SVN项目目录,则需要通过以下命令行 svnadmin create c:\mypro ...
- 【java】java内存模型 (1)--基础
并发编程模型的分类 在并发编程中,我们需要处理两个关键问题:线程之间如何通信及线程之间如何同步(这里的线程是指并发执行的活动实体).通信是指线程之间以何种机制来交换信息.在命令式编程中,线程之间的通信 ...
- tiny6410移植opencv
1.错误1, 解决办法:取消一下两个选项: 2.错误2, 解决办法: 原因是找不到pthread链接库,打开文件夹下的CmakeCache.txt进行修改 3.错误3, 解决办法:
- NHibernate初学三之条件查询(Criteria Queries)与AspNetPager分页实例
NHibernate除了SQL与HQL两种查询操作外,还有一种就是条件查询Criteria,本文将从网上整理一些Criteria的理论及小实例,最后通过一个结合AspNetPager分页来加深理解,必 ...
- 如何使用CodeSmith批量生成代码(原创系列教程)
在上一篇我们已经用PowerDesigner创建好了需要的测试数据库,下面就可以开始用它完成批量代码生成的工作啦. 下面我会一步步的解释如何用CodeSmith实现预期的结果的,事先声明一下,在此只做 ...
- Mac下,如何把项目托管到Github上(Github Desktop的使用)
在上一篇中,详细讲解了使用X-code和终端配合上传代码的方法,这种方法比较传统,中间会有坑,英文看起来也费劲,不过Github官方提供了一个Mac版的客户端,如下图:
- MySQL只有information_schema,test两个数据库
一.现象 1.今天登上数据库,用 mysql -uroot -proot 登录(本人密码是root),出现: 2.然后尝试 无密码登录,竟然登录成功: 3.查看mysql中的数据库,发现只有两个系统表 ...
- iOS Xcode制作模板类
转载请注明出处http://blog.csdn.net/uxyheaven/article/details/48419963 为什么要定义模板类 遵守代码规范可以提高代码可读性, 降低后期维护成本. ...
- echarts实现柱状图分页展示
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...