Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:13:30+00:00 2026-06-05T07:13:30+00:00

In my application I have a Students partial, that passes a collection of @students

  • 0

In my application I have a “Students” partial, that passes a collection of @students to a “student” partial. These are eventually displayed on my index page as images of students. When a user clicks on an image, I’m poping up a box with the student’s photo and some text. Now, I have a previous/next button that allows users to cycle through the students. I implemented the cycling w/out a plugin…just a simple ajax call to load the next/previous object. My problem is that I cannot detect when I’m at the last (or first) record. I need a way to probably set a url parameter on the first and last objects. So It would look like this: http://www.mysite.com/students/15?last=true

I couldn’t find a clean way to do this. I’m also not sure if I’m thinking about this the right way. Should I be attaching url parameters? Or should I somehow modify the object to add additional attributes after retrieving them from the model?

Thank you.

[EDIT]

Just wanted to make this a little clearer.
When I pop up the students lightbox, I have 2 links: previous (linking to the previous record) and next linking to the next record. I’m using the jquery $.load method to make an ajax request and load in the data I want, into a div in my lightbox, whenever I click previous or next.

$(‘previous’).click(
$(‘mydiv’).load(‘url of previous student’);
);

I get the ‘url of previous/next student’ by walking the dom tree on initial pop up. I store these so I can refer to them again.

My problem is that I cannot tell when I’m at the first student in the list or the last. I need to know this so I can disable the prev/next button. I’m thinking I can either do this through rails/ruby or through javascript. Initially, I thought that by adding a url parameter on the link or the previous/next student (to indicate whether they were first or last), then I could detect this in rails and do a simple if/else to disable the links. But I got stuck at trying to do this with the way I’m referring to the partials.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:13:31+00:00Added an answer on June 5, 2026 at 7:13 am

    ehm, I do it with my way for inspiration,maybe help you:
    Student/index
    Classic index file with ajax loading list, will_paginate and code which I wrote above. Every student have image with link, link has href something like /student/4 and remote: true.

    student show controller

    @student = Student.find(params[:id])
    

    student show js file
    classic js render “student”

    student _student.html.erb
    your view and two view helper: prev_help(params[:id]) and next_help(params[:id])

    helpers:

    def prev_help(id)
        @student = Student.find(id - 1)
        link_to("Prev". @student )  if @student.nil?        
    end
    
    def next_help(id)
        @student = Student.find(id + 1)
        link_to("Prev". @student )  if @student.nil?        
    end
    

    I don’t have time now, but If this solution will not help you, you can write me tomorrow and I’ll create sample app to test my solution and colaborate it with you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that assigns time duration to students in a day.
I trying to write an application that has a collection of students using different
I am developing a simple students information application. I have student list in my
I have prepared an application that is a small demo of Student information manipulation.
I have a web application that assigns time duration to students in a day
I have Teacher, Student, and Parent models that all belong to User. This is
I have a Student class in my application as below: public class Student {
I'm a student, and I'm trying to write an RMI application. I have 3
I see an application have used Log.info = some info where are these logs
In My application have time consuming process.There fore i try to do that operation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.