...

View Full Version : jQuery Remove and reinitiate a new easySlider instance (jquery, help please)



keane87
09-01-2010, 11:41 AM
I'm using easySlider and masonry but I'm having problems in using multiple instances of easySlider. What I'm trying to do is to remove the first instance of easySlider and then create a new instance that has new set of images.

Here's a demo: http://keanetix.co.cc/folio2010

But it doesn't seem to work correctly. When you click box#1 (CM Partners) the slider works great. But when you click on box#3 (NBCM), the slider doesn't work and notice that it adds a 'Previous' link even though it's the first frame/slide. Also, the slider doesn't work.



$(document).ready(function(){

firstClick = true;

$('div.box a.hideable').click(function(){
$('#grid').masonry({
singleMode: false,
columnWidth: 10,
resizeable: true,
itemSelector: '.box',
animate: false,
saveOptions: true
});

// if there's already a box expanded
if(firstClick == false)
{
//alert("Not first click! prev box slider "+prevsliderid);
$('a').removeClass("hidden");

$('div#' + prevboxid)
// remove previous easySlider instance
$('#'+prevsliderid).easySlider('remove');
$('div#'+prevboxid+' div').addClass('expandable');
$('div#'+prevboxid).removeClass('expanded');
$(this).find('.hideable').show('slow');
$('#grid').masonry();

// then open new clicked box
}


var boxid = $(this).attr("id");
var sliderid = $('div#'+boxid+' div.slider').attr("id");
//alert(sliderid);
$('div#' + boxid)

// show hidden content when box has expanded completely
$('div#'+boxid+' div').removeClass('expandable');
$('div#'+boxid).addClass('expanded');
$(this).find('.hideable').hide('slow');
$('#grid').masonry();

$(this).addClass('hidden');
$.scrollTo('div#'+boxid, 400);

// load easySlider for selected div
$('#' + sliderid ).easySlider();

firstClick=false;
prevboxid = boxid;
prevsliderid = sliderid;
return false;
});

});

I'm not sure if I'm doing it right. But here's the part of the code that should remove the first instance:

Code:


// remove previous easySlider instance
$('#'+prevsliderid).easySlider('remove');

Can someone help me with this?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum