"disable-with" and "confirm" do not work #315

Closed
john-999 opened this Issue Mar 19, 2013 · 12 comments

Comments

Projects
None yet
9 participants
data-disable-with

and

data-confirm

do not work:

  • with the button element
  • using: gem 'jquery-rails', '2.2.1'
  • in Rails 3.2.13, Rails 4.0.0 (beta)
  • tested in FF, Chromium, Opera

Code for "disable_with":

<button data-disable-with="Please wait..." name="button" type="submit">Click to disable</button>

Code for "confirm":

<button data-confirm="Are you sure?" name="button" type="submit">Click to confirm</button>

See it in action here: https://github.com/john-999/disable_with_issue

This issue could be related to:

badboy commented Mar 26, 2013

I can confirm this issue (no pun intended), but I could not even find a working version (tried several down to 1.0.19). data-confirm works fine on a-tags, but not on submit buttons. I built a workaround listening on the submit event for the form and display the confirmation dialogue myself.

I'm having problems with confirm too, I'm thinking it must be some conflict because it was working before... is there any known conflicts for this methods?

ymzong commented Aug 13, 2013

So is it fixed yet? Currently my app has: f.submit "Go!", :confirm=>"Are you sure?" at the end of a form, and the generated HTML is: <input data-confirm="Are you sure?" name="commit" type="submit" value="Go!" />. However, the confirmation does not work despite that the form operation works.
Any help/ideas?

tbaik commented Aug 23, 2013

I'm having the same issue! I've tried every method but I guess we have to avoid using submit for now...

ymzong commented Aug 23, 2013

Hi @shyunz,

I fixed the issue by making sure about two things:
1. In the Gemfile, you need to include `gem 'jquery-rails'`. (Run

bundle install if you just added that line)
2. In the file app/assets/javascripts/application.js, make sure to
have //= require jquery and //= require jquery_ujs.
Then, if you restart your application, the "confirm" and friends would
be working! :)

Jimmy
On Aug 23, 2013 3:31 PM, "shyunz" notifications@github.com wrote:

I'm having the same issue! I've tried every method but I guess we have to
avoid using submit for now...


Reply to this email directly or view it on GitHubhttps://github.com/rails/jquery-ujs/issues/315#issuecomment-23182079
.

jughead commented Sep 10, 2013

Hi @ymzong,

So i don't include that string because we have very big platform and this is a long story)) But btw I include jquery and jquery_ujs in layout by hand (and i see them included on a site). Any ideas, what's going on?

jughead commented Sep 10, 2013

ok, forget. I find out the mistake

ymzong commented Sep 10, 2013

@jughead, awesome!

what was the fix? @jughead

jughead commented Sep 12, 2013

@realdlee, so the problem was with understanding how it works. I think that jquery_ujs sets callbacks with .on method on document root node. But my function stopped event propagation, thus this callback was never called.

Member

lucasmazza commented Oct 31, 2013

Closing this one as the original issue was fixed. If anyone is still facing problems with confirm please open another issue describing the problem and how we can reproduce to get it fixed. Thanks everyone who walked @jughead through this one!

lucasmazza closed this Oct 31, 2013

Chrome detects if lots of JavaScript alerts are being shown and allows you to "Prevent this page from creating additional dialogs", that also prevents data-confirm links and buttons from working, as window.confirm will always return false.

If you run into this issue: closing the tab and reopening it will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment