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

Uncaught Error: The bootstrap modal plugin does not have its version defined ?!? #68

Open nick123pig opened 6 years ago

nick123pig commented 6 years ago

I've had an app running for a long time, but just started getting this error out of the blue

image

At first, it was breaking functionality in my app. I then moved data-confirm-modal to the bottom of my application.js and things started working again, but I'm still getting the error in the js console.

Here are all the pertinent files (I think)

## Gemfile
source 'https://rubygems.org'

gem 'aasm'
gem 'active_model_serializers'
gem 'activejob-retry'
gem 'acts-as-taggable-on'
gem 'aes'
gem 'animalcodes', git: 'https://github.com/crossblaim/animalcodes.git'
gem 'aws-sdk'
gem 'bootstrap-sass', '~> 3.1.1'
gem 'burgundy'
gem 'capistrano', '~> 2.15.9'
gem 'cells-rails'
gem 'cells-slim'
gem 'charlock_holmes'
gem 'coffee-rails'
gem 'delayed_job_active_record'
gem 'delayed_job_web'
gem 'devise'
gem 'devise-authy'
gem 'devise-encryptable'
gem 'devise_invitable', '~> 1.5.2'
gem 'enum_help'
gem 'enumerize'
gem 'escape_utils'
gem 'figaro'
gem 'flag_shih_tzu'
gem 'font-awesome-sass', '~> 4.5.0'
gem 'gon'
gem 'gretel'
gem 'httparty'
gem 'iconv'
gem 'jbuilder', '~> 2.4.0'
gem 'jquery-rails', '4.1'
gem 'json', '~> 1.8.3'
gem 'kaminari'
gem 'kaminari-bootstrap', '~> 3.0.1'
gem 'kaminari-cells'
gem 'nilify_blanks'
gem 'oj', '~> 2.12.14'
gem 'omniauth-google-oauth2', '~> 0.4.1'
gem 'paperclip', git: 'https://github.com/thoughtbot/paperclip.git'
gem 'paranoia', '~> 2.2'
gem 'pg'
gem 'pundit'
gem 'rack-cors', require: 'rack/cors'
gem 'rails', '4.2.9'
gem 'rails-observers', git: 'https://github.com/rails/rails-observers'
gem 'ranked-model'
gem 'ransack', '~> 1.8.8'
gem 'react-bootstrap-rails'
gem 'react-flux-rails'
gem 'react-rails', '~> 1.5.0'
gem 'redcarpet'
gem 'roadie-rails'
gem 'rollbar'
gem 'rubyXL'
gem 'rubyzip'
gem 'sass-rails', '~> 5.0', '>= 5.0.6'
gem 'schema_plus_views'
gem 'select2-rails'
gem 'simple_form'
gem 'slim-rails'
gem 'spreadsheet'
gem 'thin'
gem 'tinymce-rails'
gem 'uglifier'
gem 'underscore-rails'
gem 'whenever', require: false

# keep these at the bottom
gem 'data-confirm-modal', git: 'https://github.com/ifad/data-confirm-modal.git'

group :production do
  gem 'newrelic_rpm'
end

group :test, :development do
  gem 'annotate'
  gem 'fantaskspec'
  gem 'pry-byebug'
  gem 'rspec-rails', '~> 3.4.2'
end

group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'foreman'
  gem 'letter_opener'
  gem 'quiet_assets'
  gem 'rubocop', '~> 0.37.2', require: false
end

group :test do
  gem 'capybara', '~> 2.6'
  gem 'capybara-email'
  gem 'database_cleaner'
  gem 'factory_girl_rails'
  gem 'poltergeist'
  gem 'shoulda-matchers'
  gem 'simplecov', require: false
  gem 'timecop'
  gem 'webmock'
end
## application.js
#= require jquery
#= require jquery_ujs
#= require bootstrap
#= require react
#= require react_ujs
#= require react-flux
#= require underscore
#= require react_bootstrap
#= require_tree ./components/shared
#= require_tree ./components/app
#= require ./pickadate/picker
#= require ./pickadate/picker.date
#= require ./pickadate/picker.time
#= require ./pickadate/legacy
#= require jsoneditor
#= require ./epiceditor.min
#= require select2
#= require_tree ./shared
#= require_tree ./application
#= require data-confirm-modal

Thanks!!

joe4dev commented 6 years ago

Bootstrap introduced the modal version definition with 3.2.0: Modal.VERSION = '3.2.0' https://github.com/twbs/bootstrap/blob/v3.2.0/js/modal.js#L33

=> Updating to Bootstrap >= 3.2.0 (or adding the VERSION definition) will fix the problem where data-confirm-modal fails to detect the Bootstrap version

letungit90 commented 5 years ago

Add

<script>
  $.fn.modal.Constructor.VERSION = "3.2"
</script>

before <script src="/assets/data-confirm-modal.js"></script>

RailsCod3rFuture commented 3 years ago

any fix for bootstrap 5.0.0 beta?

tagliala commented 3 years ago

Hi @RailsCod3rFuture , please use #83 for newer bootstrap support

carmageddon888 commented 3 months ago

Hi I had upgraded to rails 5.2.8.1 from rails 4.2.11. I too saw this error in browser console.

I was on v 1.6.3 of "data-confirm-modal" gem which was doing version check. I downgraded to v 1.5.0 which did not have version check.

Did not saw the error. And also modal looked ok.

Thank you.