mois3x / sweet-alert-rails-confirm

A Rails confirm replacement with SweetAlert
MIT License
73 stars 50 forks source link

Skips confirm dialog on link_to in Rails 3.2.14 app #15

Closed weavermedia closed 8 years ago

weavermedia commented 9 years ago

My links work normally without the gem:

<%= link_to 'Delete', book, confirm: 'Are you sure?', method: :delete, remote: true %>

But when I add the gem the dialog is skipped entirely and the record is deleted without confirmation.

A regular Sweet Alert dialog works with: sweetAlert('Hello'); on the same page but the confirms fail.

It all works fine in a blank Rails 4.2 app but is failing in my 3.2.14 production app. May be a JS conflict? Any ideas where I can start debugging it?

My Gemfile:

ruby '1.9.3'

gem 'rails', '3.2.14'

group :development do
  gem 'hirb'
  gem 'rails-erd'
  gem 'quiet_assets'
  gem "bullet"
  gem 'traceroute'
  gem 'meta_request'
  gem 'thin'
end

group :development, :test do
  gem 'rspec-rails', '~> 2.14.1'
end

group :test do
  gem 'factory_girl_rails', '~> 4.2.1'
  gem 'faker', '1.3.0'
  gem 'capybara', '~> 2.1.0'
  gem 'database_cleaner', '~> 1.0.1'
  gem 'launchy', '~> 2.3.0'
  gem 'selenium-webdriver', '~> 2.38.0'
  gem 'poltergeist', '1.5.1'
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
  gem 'guard-rspec'
  gem 'spork-rails'
  gem 'guard-spork'
end

gem 'pg', '0.17.0'

group :assets do
  gem 'sass-rails',   '~> 3.2.6'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

gem 'simple_form' 
gem 'garlicjs-rails' 
gem 'figaro' 
gem 'devise',           '~> 3.0.0'
gem 's3_direct_upload' 
gem 'paperclip'  
gem 'aws-sdk' 
gem 'cancan'
gem 'will_paginate', '~> 3.0.5'
gem 'ruby-oembed' 
gem 'aws_sns_subscription'
gem 'mandrill-api',     '~> 1.0.51'  
gem 'mobvious' 
gem 'mobvious-rails' 
gem 'active_importer', github: 'continuum/active_importer', branch: 'develop'
gem 'google_drive'
gem 'google-spreadsheet-ruby'
gem 'spreadsheet'
gem 'delayed_job_active_record'
gem "daemons"
gem "workless", '~> 1.2.3'
gem 'sass', '3.2.15'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'intercom-rails', github: 'krismartin/intercom-rails', branch: 'feature/allow-nil-inbox-style'
gem 'paper_trail', '~> 3.0.6'
gem 'simplecov', :require => false, :group => :test
gem 'client_side_validations'
gem 'client_side_validations-simple_form'
gem 'autoprefixer-rails'
gem "sentry-raven"
gem 'sweet-alert-confirm', git: 'https://github.com/mois3x/sweet-alert-rails-confirm'

gem 'newrelic_rpm'
gem 'rails_12factor', group: :production
gem 'unicorn'
mois3x commented 9 years ago

Maybe a JQuery conflict? SweetAlert js lib conflict? Are you loading the js from another source than the sweet-alert-rails gem?

You can check at this part of code is where the remote confirm get override. Is the issue with all confirms? You can check the javascript console and see if any errors is thrown. If you find something let me know to fix it.

stevenspiel commented 9 years ago

I'm getting the same thing, but it is not working locally on rails 4.2.

stevenspiel commented 9 years ago

Ok, I found out it's because of jquery_ujs, which adds some javascript to method: :delete links. I found a good article on how to override it and made a gist with example implementation using sweetalert2.

mois3x commented 9 years ago

Thanks will check this.

dakotalightning commented 8 years ago

I had the same issue, i removed gem 'sweet-alert' used sweetalert.min.js from the site. And it worked.

Hope that helps