CSS-Tricks / AnythingSlider

A jQuery Slider plugin for anything.
http://css-tricks.github.io/AnythingSlider/
GNU Lesser General Public License v3.0
1.15k stars 380 forks source link

is there a way to add slides via javascript only? #490

Closed Doca closed 11 years ago

Mottie commented 11 years ago

Hi Doca!

Do you mean without using jQuery, or do you mean add slides after the slider has initialized?

Doca commented 11 years ago

sorry for not responding quickly...i meant initialize the slideshow with slides passed from javascript like an array of image information or so

Mottie commented 11 years ago

Hi Doca!

Try this (demo):

$('#slider').anythingSlider();

var t = '',
    images = [
        "http://placehold.it/300x200",
        "http://placebear.com/300/200",
        "http://lorempixel.com/300/200",
        "http://placedog.com/300/200"
    ];

$.each(images, function(i){
    t += '<li><img src="' + images[i] + '" /></li>';
});
$('#slider')
    .append(t)
    .anythingSlider(); // update slider
Doca commented 11 years ago

nice one!