Reputation: 313
I have a problem with setting a starting position, that depends on the class of item that has been clicked.
I have two lists:
1) List of previews with classes in -tags (class="1", class="2"...);
2) jcarousel list of the same items.
Second list is hidden. When user clicks at any item of the first list, the script hides first list and shows second. Also it gets the clicked item class and passes it to the jcarousel initialisation code.
$('.itemsinner A').click(function() {
var height = $('.preview_list').height();
var item = $(this).attr('class');
$('.preview_list').animate({height: 0}, 1000, function() {
$('.slider').animate({height: 500}, 1000);
});
$('#carousel').jcarousel({
wrap: 'circular',
scroll: 1,
visible: 1,
start: item
});
return false;
});
If I define start parameter for jcarousel not variable "item", but some number it all works ok. What am I doing wrong?
Upvotes: 2
Views: 1775
Reputation: 31912
Could it be a data type mismatch? Class = "1", so 'item' is a string. Does jcarousel expect a numeric value instead? Try
start: parseInt(item, 10)
Upvotes: 2