I am sending this information:
<%= observe_field "resource_focus_id",
:frequency => 0.25,
:url => { :action => :add_sub_focus},
:with => "''focus_id=''+ value +
''&sf_id=#{@resource.sub_focus_id}''",
:update => "resource_sub_focus_id" %>
Which turns out to be:
<script type="text/javascript">
//<![CDATA[
new Form.Element.Observer(''resource_focus_id'', 0.25,
function(element,
value) {new Ajax.Updater(''resource_sub_focus_id'',
''/kate/tick/admin/add_sub_focus'', {asynchronous:true,
evalScripts:true,
parameters:''focus_id=''+ value +
''&sf_id=2''})})
//]]>
</script>
All is good. Now in my controller I have:
def add_sub_focus
@sub_focuses = SubFocus.find_all_by_focus_id(@params["focus_id"])
@sf_id = @params["sf_id"]
end
My add_sub_focus.rhtml file:
<% for sub_focus in @sub_focuses do -%>
<% if #{sub_focus.id} != #{sf_id} %>
<option value="<%= sub_focus.id %>">
<%= sub_focus.name %>
</option>
<% else %>
<option value="<%= sub_focus.id %>"
selected="selected">
<%= sub_focus.name %>
</option>
<% end %>
<% end -%>
Why does the option with the value of "2" not get selected? I know
for
sure that that value is present.
If I do this:
<% for sub_focus in @sub_focuses do -%>
<% if #{sub_focus.id} == #{sf_id} %>
<option value="<%= sub_focus.id %>"
selected="selected">
<%= sub_focus.name %>
</option>
<% else %>
<option value="<%= sub_focus.id %>">
<%= sub_focus.name %>
</option>
<% end %>
<% end -%>
I think every option gets selected because the last option is display
(as selected) and that isn''t the value that should be selected.
Thanks.
Seth
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060302/9bd81fe9/attachment-0001.html