Topic: paginating carousel, that loops through groups and projects

The setup is that I have Groups and projects.  The groups has_many :projects and vise versa with belongs_to.

I want to setup a carousel that loops through the groups and displays each project in a group but then moves onto the next group.  I also need it to paginate inside the group. 

So it would load up Group 1 which contains 5 projects.  It would show the first project and have 5 pagination options, as the user clicked the next button, it would progress through Group 1's projects until it finished, then it would start on Group 2 which contains 7 projects.  It would display the first and it would show 7 pagination options...  Does that make sense?

Thanks for any help or direction you can provide.  I am using Jquery and am open to any of the available carousels.

Re: paginating carousel, that loops through groups and projects

Ok so I am learning slow but trying here.  A friend who provides a little guidance here and there is helping me without answering my questions all the way. 

His recommendation is load the first group into the Carousel, which would be easy with a simple loop.  Then he recomended using AJAX to call the next group at the end of the first group.

Using respond_to do |format|
format.js.

I am just not super clear on using AJAX for something like this.  Can anyone point me in a good direction to learn more about this?

thanks

TJ

Re: paginating carousel, that loops through groups and projects

Ok still trying here. 

I have a couple groups setup, and each group has a couple projects.  I also have a carousel setup that paginates fine.

I am trying to setup using link_to_remote  here is what I have so far:

#Group#show View
<div id="mygallery" class="stepcarousel">
    <div class="belt">
        <%= render :partial => 'group_projects'%>
    </div>
</div>
<p><%= link_to_remote "Goto Next Project Group", 
    :url => {:controller => "groups", :action => "next_project_group"}
    %>
</p>

#Groups Controller Action
def next_project_group
    render :layout => false
    respond_to do |format|
      format.js
    end
  end

#_next_project_group partial
page.insert_html :bottom, :belt, :partial => 'group_projects'

The thing I have to figure out is how to have it load the next Group by ID.  So if I am group_id 1, it would render the projects for group_id 2.

I am sure its something simple in my AJAX page.insert_html thats wrong... anyone?

thanks

Re: paginating carousel, that loops through groups and projects

I have a problem with printing ajax appropriately. So i've got a question: should only the visible part of the content be printed or should the content be allowed to  expand and take up more room than it does on the screen?

Last edited by smartstart (2012-06-19 09:59:55)