coliff / bootstrap-ie11

Internet Explorer 11 compatibility solution for Bootstrap 5
https://coliff.github.io/bootstrap-ie11/
MIT License
96 stars 15 forks source link

'BootstrapDialog' is undefined #146

Closed CecleCW closed 4 months ago

CecleCW commented 2 years ago

Hi, there I'm applying this amazing project to my website, but still, all the BootstrapDialog's gone under IE11, and it keeps saying

SCRIPT5009: 'BootstrapDialog' is undefined dialog.js (1, 581)

And here's my dialog.js

define(function (require, exports, module) {
    function showMessage(options) {
        if (typeof (options) !== 'object') return
        BootstrapDialog.show({
            title: options.title,
            message: options.message || (options.load ? messages.Loading.text : ''),
            closable: typeof (options.closable) === 'undefined' ? true : options.closable,
            closeByBackdrop: typeof (options.closeByBackdrop) === 'undefined' ? true : options.closeByBackdrop,
            closeByKeyboard: typeof (options.closeByKeyboard) === 'undefined' ? true : options.closeByKeyboard,
            type: options.type || BootstrapDialog.TYPE_INFO,
            buttons: getDialogButton(options.buttonNameList, options.callback),
            onshow: options.onshow,
            onshown: onshown,
            onhide: options.onhide,
            onhidden: options.onhidden
        })

        function onshown(dialog) {
            if (options.load) {
                dialog.getModalBody().load(options.load.url, options.load.data, function () {
                    if (typeof options.load.callback === 'function') {
                        options.load.callback(dialog)
                    }
                })
            }
            if (options.onshown) {
                options.onshown(dialog)
            }
            var inputs = dialog.$modal.find('input[type=text], input[type=password]')
            if (inputs.length > 0) {
                $(inputs[0]).focus().select()
            }
            if (options.callback) {
                dialog.$modal.keypress(function (event) {
                    if (event.keyCode == 13) {
                        event.cancelBubble = true
                        event.returnValue = false
                        var focusElements = $(":focus")
                        if (focusElements && focusElements.length > 0 && focusElements[0].tagName == 'DIV') {
                            dialog.$modal.off('keypress')  // trigger submit one time when focus on the dialog
                            options.callback({ name: 'submit' }, dialog)
                        } else {
                            options.callback({ name: 'submit' }, dialog)
                        }
                        return false
                    }
                })
            }
        }
    }
    exports.showMessage = showMessage
})

Anyone can help?

coliff commented 2 years ago

heya - not sure why you're experiencing an issue with the Modal. It is working in this simple example. https://coliff.github.io/bootstrap-ie11/tests/#modal

I'm not a JavaScript expert though so can't help any further but I'll leave this issue open for now in case anyone else can offer help.

coliff commented 2 years ago

@CecleCW - did you see the reply in https://github.com/coliff/bootstrap-ie11/issues/105 ? Maybe that might help?

CecleCW commented 2 years ago

@coliff sorry for the late reply, but #105 is not the same case. Moreover, actually in my website, there are 3 errors occurred, I'm not sure if they're related

SCRIPT1002: Syntax error bootstrap.bundle.min.js (6, 263)

SCRIPT5007: Unable to get property 'Constructor' of undefined or null reference bootstrap-dialog.min.js (1, 881)

SCRIPT5009: 'BootstrapDialog' is undefined dialog.js (1, 581)

By the way, I'm using Bootstrap v5.1.3

JMHeartley commented 4 months ago

@CecleCW, BootstrapDialog is a Bootstrap 3 object and doesn't exist in Bootstrap 5, which is the version this project supports.

coliff commented 4 months ago

thanks @JMHeartley ! I'll close this issue now then.