ifad / data-confirm-modal

Makes Rails' link_to confirm: 'foo' build a Bootstrap Modal instead of calling the browser's confirm() API.
MIT License
271 stars 115 forks source link

data-confirm-modal: The bootstrap modal plugin does not appear to be loaded #93

Closed Bodata closed 3 years ago

Bodata commented 3 years ago

I asked this question on stackoverflow... but perhaps the question better should be asked here.

I have been at this for a day now, i seem to be running in circels.

Rails 6 project with webpacker using bootstrap and jquery

ruby 2.7.4 rails 6.0.4.1 jquery 3.6.0 bootstrap 5.1.0 and data-confirm-modal 1.6.2

When the page loads the chrome debugger tells me: Uncaught Error: The bootstrap modal plugin does not appear to be loaded.

  if ($.fn.modal == undefined) {
    throw new Error("The bootstrap modal plugin does not appear to be loaded.");
  }

Jquery is working. Also i can see $ and $.fn are defined. modal is missing from the properties of $.fn

enviroment.js

const { environment } = require('@rails/webpacker')

const webpack = require('webpack')
environment.plugins.prepend('Provide',
    new webpack.ProvidePlugin({
      $: 'jquery/src/jquery',
      jQuery: 'jquery/src/jquery'
    })
)

module.exports = environment

application.js

require("@rails/ujs").start()
//require("turbolinks").start()  // gave reload bug... remove ?
require("@rails/activestorage").start()
require("channels")
//require("local-time").start()
require('jquery')

//import "./gems.js.erb"  # needs bundle exec rails webpacker:install:erb !
//import "./direct_uploads"

require('jquery-ui')

require('bootstrap')

window.jQuery = $;
window.$ = $;

import 'data-confirm-modal'

What am i missing ?

tagliala commented 3 years ago

Hi, data-confirm-modal does not support Bootstrap 5

Please check #83, you will find a workaround

Hope it helps

Closing here

Bodata commented 3 years ago

Ok.. that was quick ;-) Thanks.

So if i downgrade to bootstrap 4 this problem should disapear ? The jquery 3.6.0 is ok our should i downgrade also ?

regards, Peter

tagliala commented 3 years ago

So if i downgrade to bootstrap 4 this problem should disapear ?

BS4 should work. Otherwise you can use the experimental and unsupported file linked in #83

The jquery 3.6.0 is ok our should i downgrade also ?

jQuery should not be an issue for data-confirm-modal

abartov commented 7 months ago

(I get this error with Bootstrap 4.2.1)