I have this function which works fine except for updating the gallery information... but when i paste the code snippet in the console (chrome developer tool) it works just fine.. Here is what i paste in the console:
var obj = $('.item_info'),
arr = $.makeArray(obj);
$(".gallery-info").html(arr[0]);
Here is the complete function.
setTimeout(function() {
// If it is the about us page
if($(".page-id-7").length < 1) {
// if it has bullets
if($(".rsBullets").length) {
// move the bullets html
$(".slider_down .pull-right").addClass("rsUni").prepend($(".rsNav"));
}
}
// if page has thumbnails
if($(".rsThumbs").length) {
// get the slider
var slider = $(".royalSlider").data('royalSlider');
// move the thumbnail html
$(".footer .container-fluid").addClass("rsUni").prepend($(".rsNav"));
$(".rsNav").toggle();
// get all divs with the class item-info in an array
var obj = $('.item_info'),
arr = $.makeArray(obj);
// set the gallery-info html to the first item in the array
$(".gallery-info").html(arr[0]);
$("#slider_prev").click(function() {
slider.prev();
});
$("#slider_next").click(function() {
slider.next();
});
var curId, totalSlides = slider.numSlides;
$("#slide_count").html("1 OF "+totalSlides);
// after slider change
slider.ev.on('rsAfterSlideChange', function(event) {
curId = slider.currSlideId + 1;
// update the count
$("#slide_count").html(curId+" OF "+totalSlides);
// update the gallery info to the current item
$(".gallery-info").html(arr[slider.currSlideId]);
});
$(".royalSlider").height("640");
}
}, 0);
$(".gallery-info").html(arr[0]); just below this line i tried to alert(arr[0]) which gives undefined.
Also any performance tips will be appreciated. Thanks