Sweet alert

Hello i’m tryng to make an alert using thse sweet alert linrary : http://t4t5.github.io/sweetalert/
i have tryed to integrate the code for making an a confirmation alert for deleting an item, but when i click on the button for deleting the item these not work.
Hope you help me, thank you.

CODE BEFORE INTEGRATING SWEET ALERT:

$(".delete-link").click(function()
{
	var id = $(this).attr("id");
	var del_id = id;
	var parent = $(this).parent("td").parent("tr");
	if(confirm('Sure to Delete ID no = ' +del_id))
	{
		$.post('delete.php', {'del_id':del_id}, function(data)
		{
			parent.fadeOut('slow');
		});	
	}
	return false;
});

CODE AFTER INTEGRATING SWEET ALERT:

$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
});

swal({
title: "Are you sure you want to delete?",
text: "Sure to Delete ID no = " + del_id,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
closeOnConfirm: false
},
function(){
$.post('delete.php', {'del_id':del_id}, function(data)
		{
			parent.fadeOut('slow');
		});
});
return false;

});

Sounds like this part is not working:

$.post('delete.php', {'del_id':del_id}, function(data){
  parent.fadeOut('slow');
});	

i.e. that the Sweet Alert is displaying the dialogue, but the item is not being removed from the database. Did I get that right?

no dialog is not displayed

Ok. Could you please provide a fiddle demonstrating the problem you are having.

thank for interesting, but i have resolved.

Oh ok. What was the problem?

As the console will tell you, there’s a syntax error – there are some excess closing brackets, presumably the ones before the swal() call.

Edit: oops, x-post.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.