This project is archived and is in readonly mode.

#3963 ✓stale
Martin

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

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

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?

Comments and changes to this ticket

  • Martin

    Martin February 15th, 2010 @ 12:50 PM

    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();
        }
    
      });
    
  • Santiago Pastorino

    Santiago Pastorino January 9th, 2011 @ 10:14 PM

    • 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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages