Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Prototype UJS driver form events

#5671

At the end of the default Prototype UJS driver, the following event callback is added to re-enable the form's submit button and toggle any data-disable-with values:


document.on("ajax:after", "form", function(event, element) { ... });

I believe this callback should be based on the "ajax:complete" event instead though. Since "ajax:after" is fired immediately after the form submission, and therefore pretty much immediately after "ajax:before", there is never any time to display the "Saving..." dialogue from the data-disable-with attribute. Likewise, the submit button is immediately toggled back to an enabled state, potentially allowing unintended multiple submissions.

Reported by Aaron Reichman · September 20th, 2010 @ 05:00 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Yuval Kordov
    Yuval Kordov

    Thought I'd just add that in my case this event is simply not firing. The input text is correctly replaced with the disable text, but on the completion of the submit, the ajax:after event doesn't get triggered, so my form is left disabled with the disabled text.

    September 25th, 2010 @ 12:48 AM

  2. Yuval Kordov
    Yuval Kordov

    Sorry. Turns out it was being triggered so fast that it appeared as though it wasn't. So essentially, I'm +1ing the original issue. I've attached the restoration of the submit button to ajax:complete instead of ajax:after, as suggested, and everything functions as expected.

    September 25th, 2010 @ 12:59 AM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:59 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:59 PM

  5. Niels Meersschaert
    Niels Meersschaert
    • State changed from stale to open

    [state:open] I have been running into this issue as well. Any disable button immediately returns to it's prior state before the Ajax request has completed. Switching to ajax:complete fixes this for me.

    February 3rd, 2011 @ 08:27 PM

  6. rails
    rails

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    May 4th, 2011 @ 01:00 AM

  7. rails
    rails
    • State changed from open to stale

    May 4th, 2011 @ 01:00 AM