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?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.