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.

submit_tag :disable_with -> Problem with AJAX-Buttons in FireFox

#3963

I have a normal form with 2 submit tags.
The submit tags names, so the controller can detect, which one was clicked.
Both submit tags have a :disable_with text.
Now I open a div via ajax and render a new remote_form_for with a third button (including a :disable_with).

If I click on the ajax button and than on a "normal" button, the button name for the normal butten won't be submitted in Firefox 3.6 (in IE7, it still works).

A small test project is included.

I think, the problem is in form_tag_helper.rb, line 355:

   options["onclick"]  = "if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }"

The hiddenCommit is stored only once for the hole window. If the ajax button sets it, it will never be overwritten by the "normal" button.
Our first fix was to replace window.hiddenCommit by this.form.hiddenCommit, so every form has its one hiddenCommit.

We use the jrails plugin with jquery 1.4. Can someone verify this with prototype, please?

Reported by Martin · February 15th, 2010 @ 12:45 PM

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

Activity

  1. Martin
    Martin

    Because we didn't want to change the rails source code for our project, we used this jQuery function as replacement for the :disable_with technique.
    You can't set the disabling text, but the rest is working fine...

      $('input[type=submit]').live('click', function() {
    
        $(this).siblings('#hiddenCommit').remove();
        $(this).parent('form').append('<input type="hidden" name="'+ this.name+ '" value="'+ this.value +'" id="hiddenCommit" />');
        $(this).attr('disabled', 'disabled');
    
        var onsubmit = this.form.onsubmit ? this.form.onsubmit() : true;
        if (! onsubmit) {
          $(this).siblings('#hiddenCommit').remove();
          $(this).attr('disabled', '');
        } else {
          this.form.submit();
        }
    
      });
    

    February 15th, 2010 @ 12:50 PM

  2. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to stale
    • Importance changed from to Low

    This should be fixed now if not please let me know and I will reopen

    January 9th, 2011 @ 10:14 PM