Very nice tool, I didn't know firebug.
I think I've found the reason of the problem: When you update fields
of a form, they forget to which form_tag they belong. (Why do we need
a form_tag for these select_tags, as they are only used for setting
other fields by onchange?)
Updating another partial containing the form_tag doesn't work, so
you've got to update the whole form. But I didn't find a way to update
a table row: A <div> can't be between a <table> and a <tr> element,
and a form_tag can't be between <tr> and <td>. A simple example:
<table cellpadding=10>
<div id='test'>
<%= render :partial => 'test' %>
</div>
</table>
_test.html.erb:
<% form_tag do %>
<tr>
<td>
number: <%= select_tag :select_number,
options_for_select(['','1','2'], selected = @number),
{:onchange => remote_function(:url => {:action
=> :select_number}, :with => "select_number")} %>
</td>
<td>
letter: <%= select_tag :select_letter,
options_for_select(['','a','b'], selected = @letter),
{:onchange => remote_function(:url => {:action
=> :select_letter}, :with => "select_letter")} %>
</td>
<td>
additional: <%= text_field_tag :additional, @additional %>
</td>
</tr>
<% end %>
def select_number
@number = params[:value]
index = ['','1','2'].index(@number) || 0
@letter = ['','a','b'][index]
render :update do |page|
page.replace_html "test", :partial => "test"
end
end
def select_letter
@letter = params[:value]
index = ['','a','b'].index(@letter) || 0
@number = ['','1','2'][index]
render :update do |page|
page.replace_html "test", :partial => "test"
end
end
I also included a field 'additional' which will also be updated with
the whole form. How can I keep the values of such fields?
Thanks,
Luma
On 22 Okt., 09:02, tonypm <[EMAIL PROTECTED]> wrote:
> ps.
>
> Looking again at the code, I suspect the problem may be that you are
> updating table cells. I think i have seen something similar with ff.
> In general, I tend to always update a whole row.
>
> Tonypm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---