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 9177245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:16:48+00:00 2026-06-17T17:16:48+00:00

I was wondering what the syntax is to link to an attribute on the

  • 0

I was wondering what the syntax is to link to an attribute on the same page

I have a list of dates

   <ul>
     <% @response.each_pair do |date, movie| %>
      <li><%= link_to date_format(date), date, :class => 'scroll_to' %></li>
     <% end %>
   </ul>

These then have movies underneath each date like so

<% @response.each_pair do |date, movie| %>
    <h3 class="resultTitle fontSize13">Available on&nbsp;<%= date_format(date) %></h3>
    <% movie.each do |m| %>
      <div class="thumbnail clearfix">
        <img class="pull-left" src=<% if m.image_link %> <%= m.image_link %> <% else %> "/assets/noimage.jpg" <% end %>>
        <div class="caption pull-right">
          <%= link_to m.name, m.title_id, :class => 'resultTitle fontSize11' %>
          <p class="bio"><%= m.bio %></p>
          <p class="resultTitle">Cast</p>
          <p class="bio"><%= m.cast.join(", ") unless m.cast.empty? %></p>
          <%= link_to "Remind me", reminders_path(:title_id => m.title_id), :method => :post, :class => 'links button' %>
        </div>
      </div>
    <% end %>
  <% end %>

What i would like to achieve is that when a user clicks on a date in the list then it will take them to that date with movies on the same page

My attribute for each date is

"release_date"

Do i need to link to that, maybe a piece of Jquery aswell to scroll down to that date? or would it jump to the date in one step?

Any advice appreciated, I have linked to other pages before but not the same page like this

EDIT

I have tried this but the page just re renders

<li><%= link_to date_format(date), params.merge(:release_date => 'release_date'), :class => 'scroll_to' %></li>

Am i on the right track?

Thanks

  • 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-17T17:16:49+00:00Added an answer on June 17, 2026 at 5:16 pm

    All you need is to give your date a unique identifier and link to that in you list. For instance below we give the h3 for each date an id relative to the date object. The browser knows how to handle internal links and will simply jump to the corresponding identifier. Notice how the id of the field you’re linking to gets appended to the end of the url when you click on the link.

    <ul>
       <%- index = 0 %>
       <% @response.each_pair do |date, movie| %>
         <%- index += 1 %> 
         <li><%= link_to date_format(date), "##{index}", :class => 'scroll_to' %></li>
       <% end %>
    </ul>
    <%- index = 0 %>
    <% @response.each_pair do |date, movie| %>
        <%- index += 1 %>
        <h3 class="resultTitle fontSize13" id="<%= index %>">Available on&nbsp;<%= date_format(date) %></h3>
        <% movie.each do |m| %>
          <div class="thumbnail clearfix">
            <img class="pull-left" src=<% if m.image_link %> <%= m.image_link %> <% else %> "/assets/noimage.jpg" <% end %>>
            <div class="caption pull-right">
              <%= link_to m.name, m.title_id, :class => 'resultTitle fontSize11' %>
              <p class="bio"><%= m.bio %></p>
              <p class="resultTitle">Cast</p>
              <p class="bio"><%= m.cast.join(", ") unless m.cast.empty? %></p>
              <%= link_to "Remind me", reminders_path(:title_id => m.title_id), :method => :post, :class => 'links button' %>
            </div>
          </div>
        <% end %>
    <% end %>
    

    For the added JQuery transition you can replace

    <li><%= link_to date_format(date), "##{index}", :class => 'scroll_to' %></li>
    

    with

    <li><%= link_to_function date_format(date), "$('html, body').animate({scrollTop:$('##{index}').offset().top }, 'slow');", :class => 'scroll_to'%></li>
    

    The above isn’t exactly a DRY approach, but the important thing to abstract out of that is that you’re linking to a unique ID elsewhere on the page and not the code itself.

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

Sidebar

Related Questions

i am wondering if the basic link_to syntax is completely broken in current rails3
I'm just wondering where this syntax documented: 1 > 2 || raise(error) I have
Now that we have tremendous functionality thanks to LINQ, I'm wondering which syntax is
I was wondering what the syntax was in PHP to update a row in
Im just wondering if theres a recommended syntax validator out there anybody can recommend?
I've got the syntax down but I'm wondering if somebody can provide an illustrative
I'm having problems getting my rsync syntax right and I'm wondering if my scenario
Wondering if someone could help me. I have next to no knowledge with Ajax,
Just wondering which Xcode syntax colouring 'theme' all you guys use, and why??
I was wondering what was the most clean and understandable syntax for doing condition

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.