Collapsable Menu Problem

semibold / 2008-10-23 08:54:45   

I have added the Collapsable menu javascript on my site.

When I installed it originally, one of the sections always remained open when I refreshed the page. So, I did a search on these forums and found the code that keeps all the menus closed.

However, now when I click into one of the projects in any of the sections, it closes all the expanded menus, including the active section. Before, when i click a project in one of the sections, it just closed the other sections and left the active section open.

Ideally, I would like to have it so when you click into another section it closes the open one, so the only section open at all times, is the active one. Also, when I click one of the projects in that section, that it remains open.

Here is my js file.
Here is my index.php file.

Thanks.

AntoineLafontaine / 2008-10-23 09:11:08   

Have you opened the files... checked the code, read some javascript tutorials, tried to understand why it is behaving like it is? Compare the two scripts you've downloaded. See the differences and try to figure out why the new behavior isn't providing you the expected results...

Show us which line(s) are the cause of the problem we'll try to help you figure out a decent solution if you can't figure it out yourself.

Maybe I'm not in my best mood today, but come on...

"Here's my files, fix this for me..." you can do better ;)

Vaska A / 2008-10-23 09:24:08   

Well, the real question to ask is why are you using a version that I pulled out of commission...you should be using the original version.

I'll release an updated one later...but right now it's creating too much work for us.

semibold / 2008-10-23 09:29:10   

Sorry. I will have a look at it myself then. It's not as if I haven't tried to figure this out. I have spent about 4 hours trying to get it to work.

Vaska A / 2008-10-23 09:30:45   

I probably spent 6 months becoming very proficient with Jquery. It's all relative.

semibold / 2008-10-23 09:32:34   

Also, I'm not looking for you to fix it for me, just for some pointers. I was trying to explain myself a well as possible by including all the links.

Vaska A / 2008-10-23 09:56:31   

Yes, you're doing a fine job of things so far. This is how you learn a few things...it's how I learned the basics as well.

AntoineLafontaine / 2008-10-23 10:26:52   

I have to apologize to you semibold: my reply was harsh.

I do stick to my point and I think Vaska makes it quite clear with its comment... javascript ain't something you pick up in an evening. I do understand your frustration but the only way you will achieve your goal is by, probably, just doing some very basic jquery tutorial and forget about your "ultimate goal" in order to master some basic techniques... You can't start running a marathon one day just because you feel like it... (man my analogy is weak...)

Or wait for us (any person from the community) to come back to that script and fix it...

Or you can become a hero and fix it for everyone...

The menu you're trying to achieve is not actually easily done. You need to be able to know that no sections have been activated (clicked) in order to be able to close all the menus, but keep track of the fact that the user has clicked a menu and keep it opened when the page is reloaded... the thing is, when a page is reloaded, the javascript variables are all reinitialized... no state persist. So you need to either make your menu state persist between pages (using PHP probably) or use something already provided by indexhibit in order to know that the menu is active. By default, indexhibit insert an "active" class in its menu, so the present script is using it to know which section needs to be open. The problem is that this "active state" is also present the first time you access the site; you get a default section opened... I'm not sure if this would work, but it might be worth trying...

1. create a new section.
2. configure it so that it doesn't display itself in the menu.
3. put your main page in it.

What I expect you would get is an all closed menu on the first access. When you click a menu, it will behave like you expect it.

If you provide a link to your top page, your menu will all be collapsed...

I hope this gives you enough pointers to get your thing going on.

cruz / 2008-10-23 10:31:39   

Hmm! I found installing and tweaking the collapsable menus script pretty straightforward, you only have to pay attention to how many section you have to expand and add them to the index.php doc on your site:

  1.  <script type='text/javascript'>
  2. path = '<%baseurl%>/files/gimgs/';

$(document).ready(function()
{
    setTimeout('move_up()', 1);
    expandingMenu(0);
    expandingMenu(1);
    expandingMenu(2);
    expandingMenu(3);
    expandingMenu(4);
    expandingMenu(5);
});

this is the code example for a collapsable menu with 6 collapsable sections, note that zero counts as the first one.

cruz / 2008-10-23 10:38:03   

Ok, better now. The script tags where confusing the code tags, lol.

  1. $(document).ready(function()
  2. {
  3. ¬†¬†¬†¬†setTimeout('move_up()', 1);
  4.     expandingMenu(0);
  5.     expandingMenu(1);
  6.     expandingMenu(2);
  7.     expandingMenu(3);
  8.     expandingMenu(4);
  9.     expandingMenu(5);
  10. });
  11.  

This thread has been closed, thank you.