This time I will share jQuery Plugin and tutorial about iOS Style Dialog Popup Plugin For jQuery – Modal.js, hope it will help you in programming stack.
Modal.js is a simple, flexible, multi-purpose jQuery plugin that lets you create Apple iOS style dialog popups (alert/confirm dialog boxes, loading indicators, toast messages and action sheets) for your mobile-first web applications.
How to use it:
1. To get started, you first have to include the following JS and CSS files on the webpage.
1 |
< link rel = "stylesheet" href = "modal.css" > |
2 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
3 |
< script src = "modal.js" ></ script > |
2. Create an alert dialog with custom message and OPTIONAL alert title and callback function.
1 |
$.alert( 'Alert Content' ); |
3 |
$.alert( 'Alert Content' , 'Alert Title' ); |
5 |
$.alert( 'Alert Content' , function () { |
3. Create a confirmation dialog with custom message and OPTIONAL confirm title and confirm/cancel callback functions.
01 |
$.confirm( 'Confirm Content' ); |
03 |
$.confirm( 'Confirm Content' , 'Confirm Title' ); |
05 |
$.confirm( 'Confirm Content' , function () { |
06 |
alert( 'Confirm Callback' ); |
09 |
$.confirm( 'Confirm Content' , function () { |
10 |
alert( 'Confirm Callback' ); |
12 |
alert( 'Cancel Callback' ); |
4. Create a preloader with custom message.
1 |
$.showPreloader( 'Loading Message' ); |
3 |
setTimeout( function () { |
5. Create a loading indicator.
3 |
setTimeout( function () { |
6. Create a toast message with custom message and OPTIONAL timeout and callback function.
1 |
$.toast( 'Toast Message' ); |
4 |
$.toast( 'Toast Message' , 3000); |
6 |
$.toast( 'Toast Message' , 3000, function () { |
7. Create a custom action sheet.
13 |
onClick: function () { |
18 |
onClick: function () { |
8. Create a prompt dialog.
1 |
$( '#demo' ).click( function () { |
2 |
$.prompt( 'Default' , 'Title' , function (value){ |
3 |
alert( 'Confirm: ' +value); |
Change log:
2017-09-16
This awesome jQuery plugin is developed by zkboys. For more Advanced Usages, please check the demo page or visit the official website.