JQuery Confirm Delete With Onclick Issue
This is my confirm alert box script: $(document).ready(function(){ $('.confirm').click(function(){ var answer = confirm('Are you sure you want to delete this item?');
Solution 1:
$(document).ready(function(){
$('.confirm').click(function(){
if (confirm("Are you sure you want to delete this item?")){
// your deletion code...
return true;
}
return false;
});
});
Solution 2:
I used the same functionality for one of my webistes, where I was making the facebook type conversation system, I am sending the code example from it, please get an idea from my code, (sorry, don't have time to set your parameters in the code, so am sending the original code used in my project).
The javascript function:
<script language="javascript">
function ConfirmDelete(id)
{
var result = confirm("Are you sure you want to Delete this Conversation ?");
if (result==true)
{
window.location = "index.php?page=inbox&delete_conversation="+id;
}
}
</script>
HTML, where the title of the conversation is displayed, and an X button is displayed, by clicking on that X button the conversation will be deleted after the confirmation.
<h2>
<a href='javascript:ConfirmDelete(<?php echo $conversation['id']; ?>);'>[x]</a>
<a href="index.php?page=view_conversation&conversation_id=<?php echo $conversation['id']; ?>"><?php echo $conversation['subject']; ?></a>
</h2>
Solution 3:
Try this One Friend
$(document).ready(function () {
$('#Delete').click(function () {
var r = confirm("Are you sure want to delete. ");
if (r == true) {
return true;
}
else {
return false;
}
});
});
Solution 4:
It would be better to use an anchor in this case:
<a class="button-content confirm" href="delet-project.php?id=[project]">click me</a>
And then a similar kind of click handler:
jQuery(function($) {
$('.confirm').click(function(e) {
if (!confirm("Are you sure you want to delete this item?")) {
e.preventDefault();
}
});
});
Post a Comment for "JQuery Confirm Delete With Onclick Issue"