A question about ajax

I defines a partial see below: <%=   puts @project.version   text_field_tag "project_version", @project.version %>

I want the project version update-to-date. The first line can print the correct version value but the text field doesn't refresh to the new version.

Hi,

First of all, if you want to use puts in your views, use <% %> tags rather than <%= %> tags. Secondly, if you load your partials once you have your data object(@project) with appropriate value your page should display the same. But if you change the value of @project.version after the partial is loaded, it would not be reflected on the page until you reload the particular div which has the text field tag with the partial.

-NAYAK

NAYAK wrote:

First of all, if you want to use puts in your views, use <% %> tags rather than <%= %> tags.

    I defines a partial see below:     <%=      puts @project.version      text_field_tag "project_version", @project.version     %>

The above will puts the @project.version to the STDOUT stream, then will return the text_field_tag into the <%= %> location.

This is a subtle hair to split (and 'p' is more useful than 'puts' there), but debugging out of the top of a <%= %>, while expressing its last line, is very common...

Vishwanath Nayak wrote:

Hi,

First of all, if you want to use puts in your views, use <% %> tags rather than <%= %> tags. Secondly, if you load your partials once you have your data object(@project) with appropriate value your page should display the same. But if you change the value of @project.version after the partial is loaded, it would not be reflected on the page until you reload the particular div which has the text field tag with the partial.

-NAYAK

On Tue, Dec 30, 2008 at 6:42 PM, Zhao Yi

Hi,

This is my controller code:

def update_project_selection

   @project = Project.find(:all,:conditions=>"name='#{selected_project}' ")    render :partial => "project_version", :layout=>false end

I update the @project object before load the partial. Why does the page display the same value?

Below is the view page:

<%=         select_tag:project_selection,options_for_select(@project_names) %>

<%=   observe_field :project_selection,     :frequency => 0.5,     :update => 'ajaxWrapper',     :url => {:action => 'update_project_selection'},     :with => "'project_selection='+encodeURIComponent(value)" %>

I know what the problem. I set up a wrong update value in observe_field element.