Bootstrap Modal Remote Source Error Handling

后端 未结 3 999
自闭症患者
自闭症患者 2021-01-17 11:58

We are using Bootstrap Modal window to display some html that is loaded via a remote source. We\'re doing this via the recommended way in the Bootstrap

3条回答
  •  情话喂你
    2021-01-17 12:17

    For Bootstrap v3.3.7 , here is the solution I came up with based on Mark Fox's answer . Just find the " .load " section in your bootstrap js file, and make it look like this :

     if (this.options.remote) {
      this.$element
        .find('.modal-content')
        .load(this.options.remote, $.proxy(function (response, status, xhr) {
          if (status == 'error') {
            this.$element.find('.modal-content').html('

    Error

    '+response); } this.$element.trigger('loaded.bs.modal'); }, this)) }

    Substitute your own error message of course or whatever other code you need.

提交回复
热议问题