I took a different direction with a carousel I implemented, opting for bxSlider instead of jCarousel. This is for an image gallery I am building http://rjwcollective.com/equinox/rishi_gallery/eqgall.php
The issue I am running into is when I reset the filters, or select a different filter, the slider doesn't reset. This is the code for the inital load:
//first load
$.ajax({
type:"POST",
url:"sortbystate.php",
data:"city=&gender=&category=",
success:function(data){
//carousel
$('#thumbs').html(data);
//alert("whoa, careful there!");
$('#thumbs').bxSlider({auto: false, mode:'vertical',
autoControls: false,
autoHover: true,
pager: false,
displaySlideQty: 4,
speed:800,
infiniteLoop: true,
moveSlideQty: 4,
controls: true});
}
});//end ajax
This is the code for handling the change of a filter:
$(".statelist :input").click(function(){
var carousel = $('#thumbs').data('jcarousel');
var state = $('.statelist input:checked').attr('value');
var gender = $('.gender input:checked').attr('value');
var category =$('.category input:checked').attr('value');
$.ajax({
type:"POST",
url:"sortbystate.php",
data:"city="+state+"&gender="+gender+"&category="+category,
success:function(data){
//alert("whoa, careful there!");
$('#thumbs').html(data);
$('#thumbs').bxSlider({auto: false, mode:'vertical',
autoControls: false,
autoHover: true,
pager: false,
displaySlideQty: 4,
speed:800,
infiniteLoop: true,
moveSlideQty: 4,
controls: true});
//$('#thumbs').jcarousel('add', index, data);
}
});//end ajax
});
I referred bxSlider's documentation and it had a built-in function to handle a reset:
destroyShow(): function()
reloadShow(): function()
I am confused as to what I am doing wrong. Even tried emptying the carousel div before loading it with data, using .empty(), no dice.
Thoughts?
Edit: link to the bxSlider website: http://bxslider.com/
Solution : use reloadSlider
You should play with these two -
destroyShow()
andreloadShow()
. My guess is usingreloadShow()
only but if it doesn't work out trydestroyShow()
followed bybxSlider()
. You'll need a variable as a reference to the plugin api.Good luck
Declaring the "mySlider" variable outside the document-ready block solved the problem for me:
Alex
** Note : For the multiple bx slider reload on click of the element. *
$(function() {
By: Milan Pandya
the reloadShow funciton execute to function
destoryShow and initShow
destroyShow function delete all style and wrapper which is working fine in horizontal mode but in vertical and fade mode it also delete the content of slider
try replace condition with switch
hope this helps
As the website says: you have the
slideshowContainer
to be attached to a variable in order to use the public functions. AsreloadShow()
anddestroyShow()
are public functions, this is the only way to go. Worked perfectly for me. I've simply put abefore my function and called afterwards
$theslideshow.destroyShow();
hope this helps