This project is archived and is in readonly mode.
:disable_with option doesn't work inside a <table> tag
-
Shih-gian Lee
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
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
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
What JavaScript library is being used?
-
The_Lord
<%= javascript_include_tag :defaults %>
I don't know exactly which library is it based on.
-
Shih-gian Lee
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
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
- 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)
Are you using the Prototype rails.js or the jQuery one?
-
The_Lord
I used the standard libraries provided by rails 3.0.0.beta3 generator so I guess it's Prototype.
-
Santiago Pastorino
- 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
- State changed from open to stale
-
The_Lord
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
- State changed from stale to open
- Milestone set to 3.1
-
Jonah Burke
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
formI 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
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 formI 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
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
- State changed from open to invalid