Skip to content

Button confirmations don't work when button is outside form #376

@marnen

Description

@marnen

I'm using jquery-rails 2.2.0, but I believe this is actually a jquery-ujs bug. The problem is that confirmation alerts on <button> elements work when the element is within a form, but not when the button is outside the<form> element and uses the form attribute to refer to the form. So, for example:

<form id='my-form' action='whatever'>
  <button type='submit' data-confirm='Are you sure?'>Button 1</button>
</form>
<button type='submit' form='my-form' data-confirm='Are you sure?'>Button 2</button>

In this case, button 1 shows the confirmation alert. Button 2 does not, but simply submits the form. (I'm using Rails 3.2.13, Chrome 35, and Mac OS X 10.9, FWIW.) It doesn't look like any JavaScript errors are being thrown.

Am I doing something wrong, or is this an actual bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions