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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:57:45+00:00 2026-05-27T11:57:45+00:00

My menu renders the selected array as options. Then when an item is selected

  • 0

My menu renders the “selected” array as options. Then when an item is selected it renders it’s branches as the new options.

To keep track of traversal I create an array called select. So if someone picked the 3rd option then the 1st option then the 6th option, select = [3,1,6]

That’s easy enough just pushing the index into the array, my question is how can I use this array to create a reference to the tree?

If select is [3,1,6] I want create a function that results in a reference to tree[3][1][6] also allowing me to traverse backwards by clipping off the last value of the array.

(in coffeescript)

tree:
    name: 'name1'
    branches:[
        name: 'name2'
        branches: [
            name: 'name3'
            branches: [
                name: 'name4'
                branches:[]
            ,
                name: 'name5'
                branches:[]
            ,
                name: 'name6'
                branches:[]
            ]
        ]
    ]

current = tree

#when clicked

$('.menu li').on 'click', ()->
    select.push($(this).index())

    for value in select
         current = current+'['+value+']'

#this results in a string, not an actual reference to the tree.
  • 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-27T11:57:46+00:00Added an answer on May 27, 2026 at 11:57 am

    If I understand correctly what you need, changing the last 2 lines with the following should do the trick:

    current = tree
    for value in select
        current = current['branches'][value]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can create a menu item in the Windows Explorer context menu by adding
I want to create a menu and level select screen for my Android game
I'm having a problem related to WebKit: http://demo.frojd.se/webkit/index.html When you click Menu item 1
For example, here in StackOverflow you can se a top menu with the options:
The following code renders different layout if I remove the menu div code: the
I've build an simple control called Menu: namespace MyControls { public class MenuItem {
I have an ASP.NET application that renders a 3rd party (Telerik's) menu control under
I'm creating a navigation menu. I've to render repeater control ul-li tags and menuitems
$('#menu .sub-right').css( 'paddingLeft', $('#menu .sub-left').width() ); nor $('#menu .sub-right').css({'padding-left': $('#menu .sub-left').width()}); ...these work. What
In menu.html, I have my menu items(a href links), let's call them, menu_1, menu_2,

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.