I'm using JCarousel plugin to display dinamically added images:
var car = $("#image-carousel").data('jcarousel');
car.add(0, html);
First parameter of add method asks for a position. I've tried to give incremental positions in order to select the exact sequence of images, but add() adds the image without any order.
The question is, how may I add secuential images to jcarousel? Or alternativelly, it's possible to sort images programmatically?
At the end, I haven't found any solution using JCarousel. Instead I've sorted the inner LI items:
function _sortCarousel(a,b) {
return $(a).find("input").val() > $(b).find("input").val() ? 1 : -1;
}
$("#image-carousel li").sort(_sortCarousel).appendTo("#image-carousel");
Of course, code inside *_sortCarousel* should be changed to reflect the sorting rules you need.