Postingan lainnya
Notifikasi SweetAlert
hallo bro, saya ada codding untuk membuat notifikasi hapus data, ini script nya :
<a href="#" class="btn btn-primary btn-xs alert_notif">Delete</a>
<script>
jQuery(document).ready(function($){
$('.alert_notif').on('click',function(){
var getLink = $(this).attr('href');
swal({
title: 'Alert',
text: 'Hapus Data?',
html: true,
confirmButtonColor: '#d9534f',
showCancelButton: true,
},function(){
window.location.href = getLink
});
return false;
});
});
</script>
jika cancel tidak muncul seperti ini : swal("Cancelled", "Your imaginary file is safe :)", "error");
dan kalo OK juga tidak muncul seperti ini : swal("Deleted!", "Your imaginary file has been deleted.", "success");
mohon bantuannya bro. terima kasih.
12 Jawaban:
<pre> jQuery(document).ready(function($){ var msg = 'Confirmation Msg.'; var div = $("<div>" + msg + "</div>"); div.dialog({ title: "Confirm", buttons: [ { text: "Yes", click: function () { alert('hapus'); } }, { text: "No", click: function () { alert('cancel'); div.dialog("close"); } } ] }); });
</pre>
<pre> <script>
jQuery(document).ready(function($){
$('.alert_notif').on('click',function(){
$('<div></div>').appendTo('body')
.html('<div><h6>'+message+'?</h6></div>')
.dialog({
modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true,
width: 'auto', resizable: false,
buttons: {
Yes: function () {
// $(obj).removeAttr('onclick');
// $(obj).parents('.Parent').remove();
$('body').append('&lt;h1&gt;Confirm Dialog Result: &lt;i&gt;Yes&lt;/i&gt;&lt;/h1&gt;');
$(this).dialog("close");
},
No: function () { $('body').append('&lt;h1&gt;Confirm Dialog Result: &lt;i&gt;No&lt;/i&gt;&lt;/h1&gt;');
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
});
});
&lt;/script&gt; </pre>
pake jquery dan sweetalert versi berapa bro ?
gue pake jquery 3.1.1 dan sweetalert 1.1.3
udah gue ganti v3.3.1 masih tetep gak muncul notif nya bro ?
adblock dkk di non aktifin dl cba, di gw si fine aja hhaha
udah gue non aktifkan adbblock, masih tetap gak muncul bro.
ini script perintah delete nya :
<pre> <a class="btn btn-danger btn-md btn3d alert_notif" data-toggle='tooltip' data-original-title="Delete" style="height: 32px;" href="proses_delete.php?&id=<?php echo $b['id']; ?>"><span class="fa fa-trash"></span></a> </td> </pre>
<pre> <script>
jQuery(document).ready(function($){
$('.alert_notif').on('click',function(){
$('<div></div>').appendTo('body')
.html('<div><h6>'+message+'?</h6></div>')
.dialog({
modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true,
width: 'auto', resizable: false,
buttons: {
Yes: function () {
// $(obj).removeAttr('onclick');
// $(obj).parents('.Parent').remove();
$('body').append('<h1>Confirm Dialog Result: <i>Yes</i></h1>');
$(this).dialog("close");
},
No: function () {
$('body').append('<h1>Confirm Dialog Result: <i>No</i></h1>');
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
});
});
</script> </pre>
jika script seperti ini muncul :
<pre> <script> jQuery(document).ready(function($){ $('.alert_notif').on('click',function(){ var getLink = $(this).attr('href'); swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonClass: "btn-danger", confirmButtonText: "Yes", cancelButtonText: "No", closeOnConfirm: false, closeOnCancel: false }, function(){ window.location.href = getLink swal("Deleted!", "Your imaginary file has been deleted.", "success"); }); return false; }); }); </script> </pre>
tetapi cancel nya tidak muncul ?
coba kyk gini gan <pre> <script> jQuery(document).ready(function($){ $(document).on('click','.alert_notif', function(){ var getLink = $(this).attr('href'); swal({ title: 'Alert', text: 'Hapus Data?', html: true, confirmButtonColor: '#d9534f', showCancelButton: true, },function(){ window.location.href = getLink }); return false; }); });
&lt;/script&gt; </pre> semoga berhasil
@Sanlie dan @bosque , terima kasih banyak gan telah membantu jawabannya..