Bootbox Confirm Dialog Problems


Answer :

You may want to check the source on the "Confirm" link under "Basic Usage" on this page: http://bootboxjs.com/

Here's a snippet:

$("a.confirm").click(function(e) {     e.preventDefault();     bootbox.confirm("Are you sure?", function(confirmed) {         console.log("Confirmed: "+confirmed);     }); }); 

Assuming jQuery is available in the UI you're working on, I'd avoid using an onClick attribute in your anchor tags. Just my two cents.


I needed that too, but I changed a little few things... Take a look...

Add this function into your global "jQuery Ready" function like that:

$(document).on("click", "[data-toggle=\"confirm\"]", function (e) {     e.preventDefault();     var lHref = $(this).attr('href');     var lText = this.attributes.getNamedItem("data-title") ? this.attributes.getNamedItem("data-title").value : "Are you sure?"; // If data-title is not set use default text     bootbox.confirm(lText, function (confirmed) {         if (confirmed) {             //window.location.replace(lHref); // similar behavior as an HTTP redirect (DOESN'T increment browser history)             window.location.href = lHref; // similar behavior as clicking on a link (Increments browser history)         }     }); }); 

And just add some "data-* attributes" to your button or link like that:

<a class="btn btn-xs btn-default" data-toggle="confirm" data-title="Do you really want to delete the record 123?" href="/Controller/Delete/123"><span class="fa fa-remove"></span> </a> 

So... This way you can have a personalized question.. This is much more intuitive for your users...

Did you liked?!

See demo: jsfiddle


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?