Thursday, 5 September 2013

JQuery Accordion Wrapper Colour to Black/White on activate initialize

JQuery Accordion Wrapper Colour to Black/White on activate initialize

I have a question regarding the Accordion wrapper.
First a quick intro on what it looks like: there are three images beneath
each other (each one about the size of a facebook timeline banner). When
clicked, the active image will stay the same, but beneath it, the
accordion expands into a text filled menu.
Now: what it SHOULD do, is exchange the remaining (unactive) images for
different images (in this case black and white versions, lesser in height)
to show their 'inactiveness' so to speak. Once one of these 'inactive'
ones is clicked, it should be exchanged for the original image and expand,
while the remaining get into a state of 'inactiveness' (as described
above).
HOWEVER: this will not work with the following code, UNLESS I activate
each image once. After that it works like it should....
So: Any ideas on how to initialize ??



jQuery('#LiveAccordionWrapper[Module:moduleid]').bind('accordionchange',
function (event, ui) { if (jQuery(ui.oldHeader).length)
jQuery(ui.oldHeader).children('a').children('div').css('background-image',
jQuery(ui.oldHeader).children('a').children('div').css('background-image').replace('color.png',
'bw.png'));
if (jQuery(ui.newHeader).length)
jQuery(ui.newHeader).children('a').children('div').css('background-image',
jQuery(ui.newHeader).children('a').children('div').css('background-image').replace('bw.png',
'color.png'));
});

No comments:

Post a Comment