1

I am new to ASP.Net MVC. I am following some tutorials and am trying to create a simple bootstrap based application. I found Bootbox and I'd really like to use it, but can't seem to make it work.

I used Package Manager Console to get it:

install-package bootbox

Then I added the js file to my bundleconfig.cs in the bootstrap section:

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/bootbox.js",
"~/Scripts/respond.js"));

I am trying to use it as a test for now in an index view that lists customers. I've added this:

@section scripts
{
<script>
    $(document).on("click", "#customers .js-delete", function (e) {
        bootbox.alert({
            message: "This customer will be deleted!",
        });
    });
</script>
}

When I click the "js-delete" referenced button the page freezes. If I use the native javascript alert/confirm instead everything works fine, so I guess this might have something to do with the way bootbox is referenced, but don't know what to do next to fix this issue. Help?

Jaime Oliveira
  • 751
  • 1
  • 5
  • 13
  • 1
    Bootbox does nothing that could "freeze" your page. As [noted in the documentation](http://bootboxjs.com/documentation.html#bb-notes), though, it's not a drop-in replacement for a native prompt, since the modal function is asynchronous. You would need to cancel the event prior to showing the modal. How you then execute your "delete" action is up to you. – Tieson T. Jul 21 '18 at 20:31
  • 1
    First of all, make sure you have the correct versions of the js libraries. It appears Bootbox 4 depends on Bootstrap 3. Also make sure you've included the script and css bundles on your view. – Jasen Jul 21 '18 at 20:33
  • Using "bootbox.js" v4.3.0 (latest), "bootstrap.js" v3.3.0 and "jquery-3.3.1.js" (all supported according to bootbox documentation). – Jaime Oliveira Jul 21 '18 at 21:09
  • Don't know if relevant. Visual Studio is reporting 4 errors in the "bootbox.js" file: "eqeqeq (ESLint) Expected '===' and instead saw '=='" – Jaime Oliveira Jul 21 '18 at 21:18
  • That's just a warning from the linter, not an actual error. Version 4.4 is the latest official release of Bootbox, with a 5.x version being released whenever I can get everything squared away. – Tieson T. Jul 22 '18 at 20:31
  • You probably want to do something similar to this answer, https://stackoverflow.com/questions/39022637/bootbox-callback-form-submit-not-working-properly/39029816#39029816 – Tieson T. Jul 22 '18 at 20:32

1 Answers1

0

Don't use the comma at the end if you don't specify multiple options

bootbox.alert({
    message: "This customer will be deleted!"
});

or a simpler way

bootbox.alert("Your message here…")
jcabey
  • 11
  • 3