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.

avatar Query
@Query

61 Kontribusi 6 Poin

Diperbarui 5 tahun yang lalu

12 Jawaban:

<pre> jQuery(document).ready(function($){ var msg = 'Confirmation Msg.'; var div = $("&lt;div&gt;" + msg + "&lt;/div&gt;"); div.dialog({ title: "Confirm", buttons: [ { text: "Yes", click: function () { alert('hapus'); } }, { text: "No", click: function () { alert('cancel'); div.dialog("close"); } } ] }); });

</pre>

avatar sanlie
@sanlie

22 Kontribusi 2 Poin

Dipost 5 tahun yang lalu

malah gak muncul notifikasi nya bro ?

avatar Query
@Query

61 Kontribusi 6 Poin

Dipost 5 tahun yang lalu

<pre> &lt;script&gt; jQuery(document).ready(function($){ $('.alert_notif').on('click',function(){ $('&lt;div&gt;&lt;/div&gt;').appendTo('body') .html('&lt;div&gt;&lt;h6&gt;'+message+'?&lt;/h6&gt;&lt;/div&gt;') .dialog({ modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true, width: 'auto', resizable: false, buttons: { Yes: function () { // $(obj).removeAttr('onclick');
// $(obj).parents('.Parent').remove();

                            $(&#039;body&#039;).append(&#039;&amp;lt;h1&amp;gt;Confirm Dialog Result: &amp;lt;i&amp;gt;Yes&amp;lt;/i&amp;gt;&amp;lt;/h1&amp;gt;&#039;);
                            
                            $(this).dialog(&quot;close&quot;);
                        },
                        No: function () {                           		                              $(&#039;body&#039;).append(&#039;&amp;lt;h1&amp;gt;Confirm Dialog Result: &amp;lt;i&amp;gt;No&amp;lt;/i&amp;gt;&amp;lt;/h1&amp;gt;&#039;);
                        
                            $(this).dialog(&quot;close&quot;);
                        }
                    },
                    close: function (event, ui) {
                        $(this).remove();
                    }
                });
        });
    });
 
&amp;lt;/script&amp;gt; &lt;/pre&gt;
avatar sanlie
@sanlie

22 Kontribusi 2 Poin

Dipost 5 tahun yang lalu

barusan gw test dan work kok

avatar sanlie
@sanlie

22 Kontribusi 2 Poin

Dipost 5 tahun yang lalu

pake jquery dan sweetalert versi berapa bro ?

gue pake jquery 3.1.1 dan sweetalert 1.1.3

avatar Query
@Query

61 Kontribusi 6 Poin

Dipost 5 tahun yang lalu

jQuery v3.3.1

avatar sanlie
@sanlie

22 Kontribusi 2 Poin

Dipost 5 tahun yang lalu

udah gue ganti v3.3.1 masih tetep gak muncul notif nya bro ?

avatar Query
@Query

61 Kontribusi 6 Poin

Dipost 5 tahun yang lalu

adblock dkk di non aktifin dl cba, di gw si fine aja hhaha

avatar sanlie
@sanlie

22 Kontribusi 2 Poin

Dipost 5 tahun yang lalu

udah gue non aktifkan adbblock, masih tetap gak muncul bro.

ini script perintah delete nya :

<pre> &lt;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=&lt;?php echo $b['id']; ?&gt;"&gt;&lt;span class="fa fa-trash"&gt;&lt;/span&gt;&lt;/a&gt; &lt;/td&gt; </pre>

<pre> &lt;script&gt; jQuery(document).ready(function($){ $('.alert_notif').on('click',function(){ $('&lt;div&gt;&lt;/div&gt;').appendTo('body') .html('&lt;div&gt;&lt;h6&gt;'+message+'?&lt;/h6&gt;&lt;/div&gt;') .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>

avatar Query
@Query

61 Kontribusi 6 Poin

Dipost 5 tahun yang lalu

jika script seperti ini muncul :

<pre> &lt;script&gt; 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; }); }); &lt;/script&gt; </pre>

tetapi cancel nya tidak muncul ?

avatar Query
@Query

61 Kontribusi 6 Poin

Dipost 5 tahun yang lalu

coba kyk gini gan <pre> &lt;script&gt; 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; }); });

&amp;lt;/script&amp;gt; &lt;/pre&gt; semoga berhasil
avatar bosque
@bosque

187 Kontribusi 104 Poin

Dipost 5 tahun yang lalu

@Sanlie dan @bosque , terima kasih banyak gan telah membantu jawabannya..

avatar Query
@Query

61 Kontribusi 6 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban