# Page Inheritance Issues and AJAX Slideshow

**URL:** <https://www.ruby-forum.com/t/page-inheritance-issues-and-ajax-slideshow/111375>\
**Category:** Rails\
**Created:** [August 6, 2007, 4:58pm UTC](https://www.ruby-forum.com/t/page-inheritance-issues-and-ajax-slideshow/111375 "2007-08-06T16:58:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![garage-r-us](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@garage-r-us](https://www.ruby-forum.com/u/garage-r-us)\
**Post date:** [August 6, 2007, 4:58pm UTC](https://www.ruby-forum.com/t/page-inheritance-issues-and-ajax-slideshow/111375/1 "2007-08-06T16:58:30Z")

</div>

I’m trying to get a working AJAX slideshow of my products. Instead  
of  
just having the specified div being replaced just by the html in  
slideshow.rhtml, the div is replaced by the entire store layout.  
Mainly I think it’s a page inheritance problem that I have. The  
action, “store/slideshow”, aquires the layout of “store” when I don’t  
want it to. Does anyone have any suggestions on how to bypass this  
problem or any alternative ways of doing this, so that it just  
injects  
the rhtml from slideshow.rhtml?

Here is the script that I have:

var album = {  
startup: function() {  
new PeriodicalExecuter(album.cycle, 5) // change image every 5  
seconds  
},  
cycle: function() {  
new Effect.Fade(‘store-random-item’, { // the id of the

  
containing the photos  
duration: 1,  
fps: 50,  
afterFinish: function() {  
new Ajax.Updater(‘store-random-item’,’/store/slideshow’, { //  
URL for next ![]() tag  
asynchronous: true,  
onSuccess: function() {  
new Effect.Appear(‘store-random-item’, {  
duration: 1,  
fps: 50,  
queue:‘end’  
})  
}  
})  
}  
})  
}

}

window.onload = album.startup

Here is my slideshow.rhtml page:

```
    <div id="store-random-item">
            <h3><%= @slideshow.title %></h3>
            <img src="<%= @slideshow.image_url1.thumb.url %>
    </div>

```

Here is my layout page:

 Garagesale-R-Us.com \<%= stylesheet\_link\_tag "garage", "scaffold", :media =\> "all" %\> \<%= javascript\_include\_tag :defaults %\> \<%= javascript\_include\_tag 'slideshow' %\>

```
    </head>
    <body>
            <div id="container">
                            <div id="banner">
                                    <%= image_tag

```

“header.jpg”, :alt =\> @page\_title || “Garagesale-R-  
Us” %\>

  

  

Your garage sale superstore!

 \<%= hidden\_div\_if(@cart.items.empty?, :id =\> "cart") %\> \<%= render(:partial =\> "cart", :object =\> @cart) %\> 

 \<%= render :partial =\> 'list' %\> 
 \<% if flash[:notice] -%\> 
\<%= flash[:notice] %\>
 \<% end -%\> \<%= yield :layout %\>

```
                            <%= render 'store/slideshow' %>

                            </div>
            </div>

    </body>

```

Here is the slideshow method in my store controller:

def slideshow  
render (:layout=\>false)  
@products = Product.find(:all)  
@number = (Product.count - 1)  
@slideshow = @products[rand(@number)]  
end
