JS/JQuery newbie here. I'm using BootBox for Twitter Bootstrap, and I'm trying to pass the value of the id attribute of an a element into the callback function:
<a class="confirmdel" id="<?= $folioid ?>" href="#"> Delete</a>
<script>
$(document).on("click", ".confirmdel", function(e) {
var folioid = ($(this).attr('id'));
bootbox.dialog("Do you really want to delete this folio entry?", [{
"label" : "Yes",
"class" : "btn-danger",
"icon" : "icon-trash",
"callback": function() {
window.location.replace("deletefolio.php?folioid="+$folioid);
}
}, {
"label" : "No",
"class" : "btn",
}]);
});
</script>
It seems i can't use $(this) inside the callback function because in there it doesn't refer to the a element but to the window instead, and I have no idea how to pass the variable into the callback from outside.
Maybe I'm thinking about it the wrong way entirely.
Any suggestions greatly appreciated!