Jump to content

AJAX calls make my Javascript accordion go nuts


MDWeezer

Recommended Posts

I have a very simple site (internal to my employer, otherwise I would post the site).

 

It's a simple grid layout and on my left hand column I have a list box containing some items.  When an item is selected, an AJAX call is made to populate the main content with an accordion containing data regarding that item.  However, after a few selections from the list the accordion starts to not function properly (everything expands when clicked, only opens half way etc etc).  Pages that I use the same accordion code on that don't have any AJAX calls function fine, so the AJAX calls are doing something. 

 

Here's my code (Prototype for my AJAX calls):

 

AJAX Call:

function getLRUs(selected_value){
var url = 'getlrus.cfm';
var pars = 'id='+selected_value;
var target = 'mainBox';
var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars, asynchronous:true, evalScripts: true});
initLightbox(); 
}

 

Then I have to use an iframe inside of the returned contents to fire off the code to render my accordion which looks like this:

<iframe WIDTH=0 HEIGHT=0 FRAMEBORDER=0 onload="init();"/>

 

init() is in an included javascipt file.

 

function init() {
new Accordian('basic-accordian',5,'header_highlight');
}

 

Once I close out of my browser (IE in my corporations case...) and open it back up it will function correctly.  I'm guessing as I make each AJAX request, I'm creating more and more accordion objects?

 

Any thoughts or suggestions?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.