Problem with observe_field

Hi folks,

I have following in my view :

<%= select 'theme', "id", Theme.find_all.collect {|t| [ t.name, t.id ] }, { :prompt => 'Select a theme' } %>

<%= observe_field(
:theme_id,
:update => :my_style,
:url => { :action => :themelookup, :id => @space,},
:with => ‘theme_id’)
%>

<%= text_area 'my', 'style', :cols => '65', :rows=>'10' %>
=========================================

Basically I’m updating the text area based on selection made from
selection box. This works well. But in firefox, if I edit the value in
textbox and try to make a different selection from the selection box,
it doesnt update. This works well in IE !? Any pointers ?

Thanks,
Pratik

Pratik wrote:

%>

<%= text_area 'my', 'style', :cols => '65', :rows=>'10' %>
=========================================

Basically I’m updating the text area based on selection made from
selection box. This works well. But in firefox, if I edit the value in
textbox and try to make a different selection from the selection box,
it doesnt update. This works well in IE !? Any pointers ?

Two things to look at with your observe field call:

  1. You should be updating userfoo rather than my_style
  2. You don’t need to use the :with option


We develop, watch us RoR, in numbers too big to ignore.

That’s how I got that working. But still dont understand why I cannot
update “my_style”. It works well in IE.

Also, when I update “userfoo”, I need to write html code in my
controller. What are the common ways to keep my controller clean to
avoid this kind of cases ?

Thanks for the reply Mark.

-Pratik

Look into RJS templates. They will let you write these calls without
regenerating any HTML in the controller actions.

http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates

Jason

Just ordered Cody’s book on RJS :slight_smile:

Anyone :-s ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs