iosscripts / iosslider

iosslider is a jQuery plugin which allows you to integrate a customizable, cross-browser content slider into your web presence. Designed for use as a content slider, website banner, or image gallery.
http://iosscripts.com/iosslider
432 stars 103 forks source link

Sliders not updating #325

Closed ibrahimmumcu closed 10 years ago

ibrahimmumcu commented 10 years ago

I'm getting new image with ajax then I want to apply slider.

First off all I tried destroy slider then put div in slider and then update didnt work.

The second way I tried is removing all slide by one by then apply new div/items in slider then update did not work again.

Is anyone has solution or example?

marcwhitbread commented 10 years ago

All you need to do is add the elements within the slider using append() and then call the update public method.

If your CSS for the slide is in order, it will render correctly. What specifically "didn't work"?

ibrahimmumcu commented 10 years ago

After added new slides the ".slider" class which in ".iosSlider" class has "left: -25326px; width: 5628px;" style. That's why the slides are not showing up. @marcwhitbread

ibrahimmumcu commented 10 years ago

In first I have 10 slides. Each one of has 938px width. So being 25326 is so normal (because every slide clonenin 3 times), but after delete all slides and added new 4 slides should reset ".slider" left attribute. Right? @marcwhitbread

marcwhitbread commented 10 years ago

Ignore those left offset values. They are confusing to understand. When in infinite sliding mode, those values can be quite large normally.

What is the height of the slider being calculated to be? Can I see your implementation?

ibrahimmumcu commented 10 years ago

http://aloom.sekizbit.net/test.html you can check by change the select. @marcwhitbread

marcwhitbread commented 10 years ago

Thanks for the link. Seems like it might be a bug. Can I see your JS that is fired onchange in the select?

ibrahimmumcu commented 10 years ago

You can check by yourself. Right click > Source. :) Starting from line 465 @marcwhitbread

//change room image for configurable products
    jQuery("select").change(function(){
        var id = otherProducts[(jQuery(this)[0].selectedIndex)-1];
        if(id != undefined){
            jQuery.ajax({
                type: "POST",
                data: {id:id},
                url: "http://aloom.sekizbit.net/getProductImages.php",
                success: function(diffimages){
                    var obj = jQuery.parseJSON(diffimages);
                    console.log(obj);

                    // for(var n=1; n<=numItems; n++){
                        // jQuery(".iosSlider").iosSlider('removeSlide', n);
                    // }
                    jQuery(".iosSlider .slider").html("");
                    for(var i=0; i<obj.fullimage.length; i++){
                        var j = i+1;
                        jQuery(".iosSlider .slider").append("<div class='item' id='item"+j+"' style='width: 938px; float: left; background: url("+obj.fullimage[i]+") no-repeat center center;'></div>");
                    }
                    //jQuery(".iosSlider").iosSlider("unlock");
                    jQuery(".iosSlider").iosSlider("update");

                }
            });
        }
    });
marcwhitbread commented 10 years ago

I think I might have figured out why I can't reproduce this issue... you are running a very old version of iosslider (v1.0.35 from late 2012). I can only assume this is the problem. Please update to the latest version and let me know if the slider is now updating correctly.