I have a jQuery confirm action that doesn't open the right url. It opens the first url in the table row.
<td><a class="confirm" href="verwijderen.php?page=honden&id=<?php echo $rows['id'];?>" >Verwijder</a></td>
.
<script>
$(".confirm").confirm({
text: "Weet je het zeker?",
title: "Bevestig verwijderen",
confirm: function(button) {
window.document.location = $(".confirm").attr("href");
},
cancel: function(button) {
return false;
},
confirmButton: "Ja, dat weet ik zeker",
cancelButton: "Nee",
post: true
});
</script>
The problem is the jQuery confirm script only executes the first url in the list - in this case id=1. For all the other items in the table it executes id=1 also. When I hoover the url's in the table rows it shows the correct id's, like id=6. On execution of the script, it goes wrong.
Any ideas?
This should resolve your issue:
$(".confirm").each(function(i,confirm) {
$(confirm).confirm({
text: "Weet je het zeker?",
title: "Bevestig verwijderen",
confirm: function(button) {
window.document.location = $(confirm).attr("href");
},
cancel: function(button) {
return false;
},
confirmButton: "Ja, dat weet ik zeker",
cancelButton: "Nee",
post: true
});
});