Search code examples
javascripttwitter-bootstrapbootstrap-4bootstrap-modalbootbox

bootboxjs invalid prompt type - example from documentation doesn't work


I am trying to use http://bootboxjs.com/examples.html#bb-prompt in my project, so naturally I started by using their example code to see if it runs.

As per the documentation; I am using latest bootstrap, jquery and bootstrap js and then loading the bootboxjs. This is the code I am trying to run:

bootbox.prompt({
    title: "This is a prompt with a set of radio inputs!",
    message: '<p>Please select an option below:</p>',
    inputType: 'radio',
    inputOptions: [
    {
        text: 'Choice One',
        value: '1',
    },
    {
        text: 'Choice Two',
        value: '2',
    },
    {
        text: 'Choice Three',
        value: '3',
    }
    ],
    callback: function (result) {
        console.log(result);
    }
});

When this code executes; I am getting this error:

Uncaught Error: invalid prompt type

enter image description here

This is a pretty sweet library and I'd love to use it in my project; but I am a bit stumped. Any ideas?


Solution

  • I've solved the issue. I had initially used just bootbox.min.js but it turns out I need to use bootbox.locales.min.js also. I should've rtfm...

    Also, I use webpack (via laravel-mix) to bundle all the libs into one .js file, so using the bootbox.all.min.js (Production build with locales) as the last thing I load seemed to have helped also.

    This is my webpack.mix.js config file that works for me:

    const mix = require('laravel-mix');
    
    mix
        .copyDirectory('resources/libs/font-awesome/fonts', 'public/fonts')
        .styles(
            [
                // snipped...
            ],
            'public/css/app.css'
        )
        .scripts(
            [
                'resources/libs/jquery/jquery-3.4.1.min.js',
                'resources/libs/bootstrap/bootstrap.bundle.min.js',
                // bunch of other js libs...
                'resources/libs/bootbox/bootbox.all.min.js',
            ],
            'public/js/app.js'
        );