I have a rails project, where there are three divs on a page - search,
results, images. When I enter a search query in the search div, a
link_to_remote updates the results div with the results. Each result
is in turn a link_to_remote that calls render :partial on the images
div to show images for that result.

When i first get some results, the results show up fine. When I click
on a result the first time, the images show up, and its good. When I
click on another result link, the images show up, but the results pane
gets wiped out. Can anybody help?


The relevant code is below (only relevant parts are shown) - the
partials for results and images are not shown, as they are trivial:


<%= javascript_include_tag :defaults%>
<div id='query-div'>
<%= text_field_tag :phrase%>
<%=link_to_remote "Go",
        :url => {:action => 'show_results'},
        :with => "$('phrase').serialize()"

                <td style='width: 50%; border: 2px solid black;'>
                        <div id='results-div'/>
                <td style='width: 50%; border: 2px solid black;'>
                        <div id='images-div'/>

# home_controller.rb

def show_results

  phrase = params[:phrase]
  @query = Query.new
  @query.phrase = phrase
  @result_names = @query.results.map{|r| r.name}
  render :update do |page|
    page.replace_html 'results-div', :partial => 'results'

def show_images

        result_name = params[:result_name]

        phrase = params[:phrase]

        @result = Result.find_by_name(result_name)

        @images = @result.images
        render :update do |page|
          page.replace_html 'images-div', :partial => 'images'

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to