Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jquery accordion issue

Status
Not open for further replies.

Clint0890

Programmer
Jul 28, 2010
5
US
I have a navigation bar that uses a jquery accordion to expand/collapse menu items. The issue I'm having is randomly when you log into the site all menu items will be expanded, and when you click on them nothing happens (won't collapse). Has anyone else experienced this? Thanks.
 
Without any code its hard to say, but I would assume it has something to do with the property controlling the accordion not getting properly set when the page loads.

For instance if your accordion is controlled by the height of the containing element, I would expect its height to be set to something that hides the contents. If this is done via jquery or JS and there's a error somewhere it may never get to that part of the code to set the property.

also, if the accordion is dynamically generated it may be trying to target the element before its fully rendered, therefore causing an invalid reference to it, and no way to actually set its initial state.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
there is a problem with either the html or the javascript and not necessarily related to the accordion itself. also which browser are you experiencing this problem.

FF will "fix" malformed html, while IE doesn't. another example.. FF has the console and IE doesn't, if you have a console.log() line in your script the script will fail in IE.

you will need to provided code and mark up though if want help. otherwise we are in the dark.

if this is happening "randomly" then my guess is the accordion and associated markup is fine, the problem may be other scripts/markup that is conditionally applied.

finally... check the caching both ajax requests and local browser cache. if you have updated the scripts and deployed them your end users may not have the latest scripts. their browser is pulling a older version from it's local cache.


Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Validating the page will also help pinpoint any errors that may be interfering with the accordion.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Yeah I was affraid this would not be an easy question to answer. I guess I was hoping this was a common issue and the fix would be obvious. Does the below code help at all?

jQuery().ready(function(){
jQuery('#mainmenu').Accordion({
active: false,
header: '.menuHead',
alwaysOpen: false,
navigation: true,
animated: false
});
});
 
alwaysOpen doesn't appear to be a configuration option of accordion, but this wouldn't break functionality.
[tt]active: false[/tt] only works if [tt]collapsible: true[/tt]. again this wouldn't break functionality you just could not close a menu.
finally, [tt]Accordion[/tt] is not a function of jquery ui, but [tt]accordion[/tt] is. This would break functionality every time, not sometimes.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
alwaysOpen: false, allows the user to collapse the menu item even if no other items are open (basically so all items are collapsed). Also, I believe Accordion with an "A" is the correct function name.
 
not according to the docs.
of course if you are using a previous version of jquery ui (1.7 or less) then the api may be different. in which case I would update to the latest stable release (1.8.2)
You may want to move this question to the [link forums.jquery.com]jquery forum[/url]. it would make sense the product's forum would have more insight into jquery than a generic javascript forum.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top