This project is archived and is in readonly mode.

#4723 ✓invalid
The_Lord

:disable_with option doesn't work inside a <table> tag

Reported by The_Lord | May 29th, 2010 @ 12:51 PM | in 3.1

As in the title.

Steps to reproduce:
Create a form with a submit including a :disable_with => "Something" option - it works.
Now wrap the form in a

tag and try it out again - it doesn't disable the button anymore.

This doesn't happen for the :confirm option.

I'm using edge Rails 3 on 64-bit Gentoo Linux

Comments and changes to this ticket

  • Shih-gian Lee

    Shih-gian Lee May 29th, 2010 @ 02:39 PM

    Confirmed that when wrapping a table tag around a form, :disable_with does not work.

    <table>
     <%= form_for(@product) do |f| %>
       ...
       <div class="actions">
        <%= f.submit :disable_with => "Processing ..." %>
      </div>
     <% end %>
    </table>
    
  • Shih-gian Lee

    Shih-gian Lee May 29th, 2010 @ 03:04 PM

    However, when wrapping a form around a table, :disable_with works.

     <%= form_for(@product) do |f| %>
       <table>
          ...
          <div class="actions">
            <%= f.submit :disable_with => "Processing ..." %>
          </div>
       </table>
     <% end %>
    
  • The_Lord

    The_Lord May 29th, 2010 @ 05:14 PM

    Yeah, but my form is a partial (I use it just to generate this button, because button_to doesn't take the :disable_with option) and if I wrap just the content of the form in this tag it doesn't look that pretty. The whole form needs to be wrapped. Besides it is a bug anyway I think ;) I can live with it, but it should be fixed just as any other bug. Thanks for trying to come up with a workaround, but it ain't what I need.

  • Neeraj Singh

    Neeraj Singh May 29th, 2010 @ 06:41 PM

    What JavaScript library is being used?

  • The_Lord

    The_Lord May 29th, 2010 @ 10:26 PM

    <%= javascript_include_tag :defaults %>

    I don't know exactly which library is it based on.

  • Shih-gian Lee

    Shih-gian Lee May 30th, 2010 @ 02:25 AM

    Correction on my previous example. I got lazy and didn't construct a well-formed html in my example. The form works in a table tag:

    <table>
      <tr>
        <td>
            <%= form_for(@product) do |f| %>
              ...
              <div class="actions">
                <%= f.submit :disable_with => "Processing ..." %>
              </div>
            <% end %>
            </td>
        </tr>
    </table>
    
    The JavaScript library used is rails.js, which is the default js library.
    
    Can you share some snippets of your code here?
    
  • The_Lord

    The_Lord May 30th, 2010 @ 02:56 AM

    Well your example works, but it still doesn't look like what I need since inside the td tag my styling stops working (float: right; to be exact) and I need to wrap the content of the form in an additional tr tag, which again breaks the :disable_with option. My code is practically identical to the example you provided, except I use a small tag instead of div and have additional label for the submit button. Both the label and the value of the button are assigned by the I18n::t method, but I doubt it is relevant.

    <table>
      <tr>
        <td>
          <%= form_for :book, :url => { :action => :publish, :id => book.id } do |form| %>
            <small class="right"><%= book.published == true ? t(:published) : t(:not_published) %>
            <%= form.submit book.published == true ? t(:hide) : t(:publish), :disable_with => t(:please_wait), :confirm => t(:are_you_sure?) %></small>
          <% end %>
        </td>
      </tr>
    </table>
    

    In this example it works, but doesn't take the class="right" into account so it doesn't look quite as I would want it to. If you wrap the content of the form, as I said before, in an additional tr it breaks the disable_with again.

  • Aaron Patterson

    Aaron Patterson June 25th, 2010 @ 11:58 PM

    • Assigned user changed from “Aaron Patterson” to “Yehuda Katz (wycats)”

    I think Yehuda might know how to fix this better than me.

  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) June 26th, 2010 @ 12:02 AM

    Are you using the Prototype rails.js or the jQuery one?

  • The_Lord

    The_Lord June 26th, 2010 @ 12:05 AM

    I used the standard libraries provided by rails 3.0.0.beta3 generator so I guess it's Prototype.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:01 PM

    • State changed from “new” to “open”
    • Tag changed from rails 3.0.0.beta3, disable_with, table to rails 300beta3, disable_with, table
    • Importance changed from “” to “Low”

    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.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:01 PM

    • State changed from “open” to “stale”
  • The_Lord

    The_Lord February 9th, 2011 @ 12:50 AM

    Well I can confirm that the issue still exists on master. It doesn't work with neither Prototype, nor Jquery (via the jquery-rails gem). However despite trying it on master and digging through the code a little I still haven't been able to locate the problem. It's strange that it doesn't work for both Prototype and Jquery. Could this be an issue with JavaScript in general handling the table tag? It certainly isn't browser-specific as I tried it on Chromium, Firefox, Opera, Epiphany and Links ;].

    I have to admit that my skills currently aren't sufficient to research this any further.

    Since it isn't that big an issue I think it can remain stale until someone wiser than me runs out of more important ones. Cheers and keep up the great work Rails Team! :)

  • Santiago Pastorino

    Santiago Pastorino February 9th, 2011 @ 02:19 AM

    • State changed from “stale” to “open”
    • Milestone set to 3.1
  • Jonah Burke

    Jonah Burke February 26th, 2011 @ 03:28 AM

    I looked into this issue, and I don't think it's a bug. As Shih-gian points out, the submit button fails to dim only when the form is not within a td (e.g. when the form is a child of the table). This is invalid HTML. The reported behavior is a result of how Gecko and WebKit parse this invalid HTML. They move the input outside the form (and the table), so when disableFormElements in rails.js (either version) looks at the form, there are no inputs to disable.

    For example, the following markup

    yields the following DOM:

    input
    table
    form

    I can't imagine why anybody would want to use this markup. It's invalid, and if you really want the input outside the table (but why would you?), just put it there. This bug should be resolved by design.

  • Jonah Burke

    Jonah Burke February 26th, 2011 @ 03:30 AM

    Whoops, here's another try, with proper formatting:

    I looked into this issue, and I don't think it's a bug. As Shih-gian points out, the submit button fails to dim only when the form is not within a td (e.g. when the form is a child of the table). This is invalid HTML. The reported behavior is a result of how Gecko and WebKit parse this invalid HTML. They move the input outside the form (and the table), so when disableFormElements in rails.js (either version) looks at the form, there are no inputs to disable.

    For example, the following markup

    <table>
      <form>
        <input/>
      </form>
    </table>
    

    yields the following DOM:

    input
    table
      form
    

    I can't imagine why anybody would want to use this markup. It's invalid, and if you really want the input outside the table (but why would you?), just put it there. This bug should be resolved by design.

  • The_Lord

    The_Lord February 26th, 2011 @ 09:56 PM

    That's true. I was young and too stupid to use HTML validators when I filed this. Please mark this as invalid and call me 'idiot'. Sorry :/

  • Santiago Pastorino

    Santiago Pastorino February 27th, 2011 @ 04:01 AM

    • State changed from “open” to “invalid”
  • bingbing

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>

Pages