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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:18:41+00:00 2026-05-15T02:18:41+00:00

I’m using Unobtrusive Toggling in a view that contains many records (Orders). I’ve got

  • 0

I’m using Unobtrusive Toggling in a view that contains many records (Orders). I’ve got it working on individual divs, but I now want it to work so each Order can be expanded/contracted individually within the loop using its own toggle link (the link is also looped).

When my expandable div is called x, the problem is every loop of the toggle button just toggles the first div instead of the div in its own iteration – I imagine the best way is to use the order_id for the identifier of each expandable section?

More experienced viewers might laugh at this 🙂 but I tried playing around with code such as:

<% for order in @orders do %>

# toggle
<a class="toggle" href="#<%= order.id %>" rel="toggle[<%= order.id %>]">Toggle</a>

# expandable div with its own nested toggle
<div id="<%= order.id %>" class="expand_me">
    # nested toggle inside the looping expandable div
    <a class="toggle" href="?" rel="toggle[?]">Toggle</a>
    <div id="?" class="expand_me">
    ...
    </div>
</div>

<% end %>

As you can see, within each of these loops there are some sub-sections I’d like to be able to toggle as well. How would the solution change if I have to be able to toggle multiple divs WITHIN the expandable looped div? The ?s are because if I refer to the main toggle div as order.id then I don’t know how to refer to multiple internal divs – this is obviously pursuant to the main problem.

  • 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-05-15T02:18:42+00:00Added an answer on May 15, 2026 at 2:18 am

    Have you looked into a JavaScript library such as Jquery for doing this? You should be able to do this without needing to add any special classes or IDs. If the <a> link is just to toggle the proceeding <div>, then you can just have the JavaScript move to the next element in the DOM.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the

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.