BootBox JS for Twitter Bootstrap - how do I pass data to a callback function?

JS / jQuery newbie here. I am using BootBox for Twitter Bootstrap and I am trying to pass the value of the id attribute of an element to a 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 not use $ (this) inside the callback function, because there it does not refer to the element a, but to the window, and I do not know how to pass the variable to the callback from the outside.

Perhaps I think about it completely wrong.

Any suggestions that were highly appreciated!

+4
source share

Source: https://habr.com/ru/post/1480101/


All Articles