user2670802
user2670802

Reputation: 11

Unslider arrow code overriding slider options

Not sure why but whenever I add the arrows part my options get overridden. Not the best at jquery and javascript so if you guys can help point out what I am not seeing. I tried adding the options in the second part and nothing.

$=jQuery;   
$('.slider').unslider({
speed: 500,               //  The speed to animate each slide (in milliseconds)
delay: 33000,              //  The delay between slide animations (in milliseconds)
complete: function() {},  //  A function that gets called after every slide animation
keys: false,               //  Enable keyboard (left, right) arrow shortcuts
dots: true,               //  Display dot navigation
fluid: false              //  Support responsive design. May break non-responsive
});
// This overrides my options above.
var unslider = $('.slider').unslider();
$('.unslider-arrow').click(function() {
    var fn = this.className.split(' ')[1];
    //  Either do unslider.data('unslider').next() or .prev() depending on the className
    unslider.data('unslider')[fn]();

});

Upvotes: 1

Views: 1006

Answers (1)

Olivier Albertini
Olivier Albertini

Reputation: 694

i'm not sure to understand but, i think that it'll work

$(document).ready(function(){
    var unslider = $('.slider').unslider({
    speed: 500,               //  The speed to animate each slide (in milliseconds)
    delay: 33000,              //  The delay between slide animations (in milliseconds)
    complete: function() {},  //  A function that gets called after every slide animation
    keys: false,               //  Enable keyboard (left, right) arrow shortcuts
    dots: true,               //  Display dot navigation
    fluid: false              //  Support responsive design. May break non-responsive
    });
    $('.unslider-arrow').click(function() {
        var fn = this.className.split(' ')[1];
        //  Either do unslider.data('unslider').next() or .prev() depending on the className
        unslider.data('unslider')[fn]();

    });
});

Upvotes: 2

Related Questions