alertifyLight
combination between alertify and jquery
Install using bower
bower install alertifylight
Initialize the plugin
<link rel="stylesheet" type="text/css" href="http://fabien-d.github.io/alertify.js/assets/js/lib/alertify/alertify.core.css">
<link rel="stylesheet" type="text/css" href="http://fabien-d.github.io/alertify.js/assets/js/lib/alertify/alertify.default.css">
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="http://fabien-d.github.io/alertify.js/assets/js/lib/alertify/alertify.min.js"></script>
<script src="dist/js/alertifylight.min.js"></script>
Online Source
<script src="http://rachmanzz.github.io/alertifylight/dist/js/alertifylight.min.js"></script>
Using
$('#yourID').click(function(){
alertifylight.$confirmPost("my message", // $confirmGet for GET Method
{
url : "yourUrl",
input : {
name : "Your Input"
}
},function(isConfirm,data,callback){
if(isConfirm){
callback('your txt');
}else{
callback('your txt');
}
});
});
post data:
url : "yourUrl" // your url to post data
input:{
"name" : "value" // name and value of input
}
alert confirm :
if(isConfirm){
// if alert confirm == true
}else{
// false
}
get data after post:
data.status // get status after your data is submit. return true/false
data.data // obtain raw data
data.value // data have been parse to Json
show alert after confirm:
callback('your txt'); // if isConfirm == true, swal type will be set "success" / false will be set "error"
Alert prompt
alertifylight.$promptPost("your message","your URL","default text",function(isConfirm,data,callback){
// your code here
}); // name of input = data
Custom name of input
alertifylight.promptPost(
"your message","your url","default text",
function(isConfirm, str,callback){
if(isConfirm){
callback({name:str},function(data,callback){ // you can change name to any key
callback("your message");
});
}else{
callback("your message");
}
}
);