Twitter bootstrap 3 我们可以使用引导模式背景作为独立组件吗

Twitter bootstrap 3 我们可以使用引导模式背景作为独立组件吗,twitter-bootstrap-3,bootstrap-modal,Twitter Bootstrap 3,Bootstrap Modal,我的问题是,如果我必须将Background用于其他用途,我可以将bootstrap的模态插件的Background作为一个单独的独立组件来使用吗。 如果可能,那么如何使用它。 提前感谢您不能将引导背景作为独立组件使用 我已经编写了以下js函数,继承自bootstrap,用于使用background 该函数使用类似jquery的引导 var backdrop = function () { var that = this var animate = 'fa

我的问题是,如果我必须将Background用于其他用途,我可以将bootstrap的模态插件的Background作为一个单独的独立组件来使用吗。 如果可能,那么如何使用它。
提前感谢

您不能将引导背景作为独立组件使用

我已经编写了以下js函数,继承自bootstrap,用于使用background

该函数使用类似jquery的引导

    var backdrop = function () {
        var that = this
        var animate = 'fade'
        that.$body = $(document.body)
        that.__TRANSITION_DURATION = 300
        that.__BACKDROP_TRANSITION_DURATION = 150

        this.show = function (callback) {
            var doAnimate = $.support.transition && animate

            that.$backdrop = $(document.createElement('div'))
              .addClass('modal-backdrop ' + animate)
              .appendTo(that.$body)

            if (doAnimate) that.$backdrop[0].offsetWidth // force reflow

            that.$backdrop.addClass('in')

            if (!callback) return

            doAnimate ?
              that.$backdrop
                .one('bsTransitionEnd', callback)
                .emulateTransitionEnd(that.__BACKDROP_TRANSITION_DURATION) :
              callback()
        }

        this.hide = function (callback) {

            if (that.$backdrop) {
                var callbackRemove = function () {
                    that.$backdrop && that.$backdrop.remove()
                    that.$backdrop = null
                    callback && callback()
                }

                $.support.transition ?
                    that.$backdrop
                    .one('bsTransitionEnd', callbackRemove)
                    .emulateTransitionEnd(that.__BACKDROP_TRANSITION_DURATION) :
                    callbackRemove()
            }
        }

        return this
    }
这是使用它的代码:

      function showBackdrop() {

            var bd = new backdrop()
            bd.show(function () { })
            setTimeout(function () { bd.hide() }, 2000)
        }
在这两个函数中,show和hide都有一个用于执行自定义操作的回调函数,与bootstrap完全相同

    var backdrop = function () {
        var that = this
        var animate = 'fade'
        that.$body = $(document.body)
        that.__TRANSITION_DURATION = 300
        that.__BACKDROP_TRANSITION_DURATION = 150

        this.show = function (callback) {
            var doAnimate = $.support.transition && animate

            that.$backdrop = $(document.createElement('div'))
              .addClass('modal-backdrop ' + animate)
              .appendTo(that.$body)

            if (doAnimate) that.$backdrop[0].offsetWidth // force reflow

            that.$backdrop.addClass('in')

            if (!callback) return

            doAnimate ?
              that.$backdrop
                .one('bsTransitionEnd', callback)
                .emulateTransitionEnd(that.__BACKDROP_TRANSITION_DURATION) :
              callback()
        }

        this.hide = function (callback) {

            if (that.$backdrop) {
                var callbackRemove = function () {
                    that.$backdrop && that.$backdrop.remove()
                    that.$backdrop = null
                    callback && callback()
                }

                $.support.transition ?
                    that.$backdrop
                    .one('bsTransitionEnd', callbackRemove)
                    .emulateTransitionEnd(that.__BACKDROP_TRANSITION_DURATION) :
                    callbackRemove()
            }
        }

        return this
    }
注意。必须设置show回调函数才能生效。对于隐藏功能,它不是必需的