user1184100
user1184100

Reputation: 6894

Extend doesn't seem to work in jquery plugin

I'm creating a basic jquery plugin but the extend doesn't seem to work..

I'm calling the plugin in below manner

 $('#ccontainer').slide("/json/service.json",6000,700,'true','true','right','800px');

Plugin

(function($) {

$.fn.slide = function(settings) {

    var options = {
        service : '',
        slideAnimationTime : 5000,
        slideSpeed : 800,
        onHoverPause : 'true',
        autoSlide : 'true',
        direction : 'right',
        width : ''
    };

    $.extend(options , settings);
    console.log(options.slideSpeed); //doesn't show up new settings as 700 in above case but instead shows old value 800 
}

Upvotes: 1

Views: 191

Answers (1)

Andreas Wong
Andreas Wong

Reputation: 60526

I think you need to explicitly pass in an object like:

$('#container').slide({
   service: "/json/service.json",
   slideAnimationTime: 6000,
   slideSpeed: 700,
   ... // the rest of properties
});

Upvotes: 1

Related Questions