views:

51

answers:

0

I'm trying to implement a carousel function that's ajax driven. In other words, fetching new "slides" through the controller". I'm using glider.js (with prototype).

My RJS file needs to load the new element into the DOM, and then Glider is called.

My simplified RJS looks like this:

page.insert_html :bottom, "content", :partial => 'posts', :object => @posts
page.call 'new Glider("content").previous'

The problem is that page.insert_html is not being executed before the Glider command. Which means that "new Glider()" statement does not find the new content that's been added to the page. I believe this may be because page.insert_html is only executed after the whole RJS template is sent to the client.

How can I make the page.insert_html execute before the "new Glider()" statement?