I'm making an Instagram image slider feed, and it's working fine in Chrome, Safari, Firefox and Opera, but it fails in all versions of IE. It doesn't even give me an error message, it just does nothing.
I needed to return the height of the images to the parent div to get the correct height for the background.
In IE the first image is loaded up and then nothing happens after that, it doesn't even return the height of the first image. I've searched around and think it might have something to do with .children() and .each() not working correctly in IE, but I'm not sure.
So is this the cause of a IE/jQuery compability issue? or is it something else? and is there an alternative way of doing this? (I have removed most of the Auth token for security purposes)
her is a jfiddle of the result: http://jsfiddle.net/5ACr9/embedded/result/
(function($){
$.fn.MySlider = function(interval) {
var slides;
var cnt;
var amount;
var j;
function run() {
// hiding previous image and showing next
$(slides[j]).fadeOut(1000).removeClass("selected");
j++;
if (j >= amount) j = 0;
$(slides[j]).fadeIn(1000).addClass("selected");
// loop
setTimeout(run, interval);
}
slides = $('#insta-slider').children();
amount = slides.length;
j=0;
setTimeout(run, interval);
};
})(jQuery);
// custom initialization
jQuery(window).load(function() {
$('.smart_gallery').MySlider(5000);
//gets the height of the first image and returns it to parent
$( "#insta-slider" ).each(function() {
var newHeight = 0, $this = $( this );
$.each( $this.children(), function() {
newHeight = $( this ).height();
});
$this.height( newHeight );
});
var tid = setTimeout(resize, 5000);
function resize(){
//returns the height of each image after the first one
$( "#insta-slider" ).each(function() {
var newHeight2 = 0, $this = $( this );
$.each( $this.children(".selected"), function() {
newHeight2 = $( this ).height();
});
$this.height( newHeight2 );
});
tid = setTimeout(resize, 5000);
}
});