JQuery horizontal accordion close on click - help me fix this bug!

Demo: http://vincent-massaro.com/map/

This map/accordion combo works by either clicking a marker on the map or a slice of the accordion. I just noticed one slight issue. When clicking on an image slice, and then clicking to close it, it is not possible to click and open the same slice without clicking and opening a different slice first. Any help is much appreciated!
vmassaroAsked:
Who is Participating?
 
StealthyDevCommented:
Hi again!

I have changed the haccordion.js. Please find the attached file.

Now you dont need to use isMarker = true;
            GEvent.addListener(marker, 'click', function(){
                  haccordion.expandli('slices', 0);
            });

            GEvent.addListener(marker2, 'click', function(){
                        haccordion.expandli('slices', 1);
            });

Best Regards.

P.S.:
Changes:
----------------------------
$target.click(function(){
      if($($target).attr("isOpen") == 1)
      {
            $(this).stop().animate({width:config.paneldimensions.peekw}, config.speed) //contract previous content
            $($target).attr("isOpen", "0");
      }
      else
      {      
            haccordion.expandli(config.accordionid, this);
      }
})
---------------------------
      expandli:function(accordionid, targetli){
            var config=haccordion.accordioninfo[accordionid]
            var $targetli=(typeof targetli=="number")? config.$targetlis.eq(targetli) : (typeof targetli=="string")? jQuery('#'+targetli) : jQuery(targetli)
            if (typeof config.$lastexpanded!="undefined") //targetli may be an index, ID string, or DOM reference to LI
                  config.$lastexpanded.stop().animate({width:config.paneldimensions.peekw}, config.speed) //contract last opened content
            $targetli.stop().animate({width:$targetli.data('hpaneloffsetw')}, config.speed) //expand current content
            config.$lastexpanded=$targetli
            $($targetli).attr("isOpen", "1");
      }
----------------------------
haccordion.js
0
 
StealthyDevCommented:
Please test the above file and get back to me on this.

Best Regard.

0
 
vmassaroAuthor Commented:
It works perfectly now! Thank you again!
0
 
vmassaroAuthor Commented:
Superb job!
0
 
StealthyDevCommented:
Any-time...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.