Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Quick question about jQuery plugin settings?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #40809
    JohnMotylJr
    Participant

    Im having trouble calling my speed for my plugin. The code following is not the extent of my plugin, it is just for testing.
    Basic Plugin:

    (function($) {

    $.fn.colorspan = function(options) {
    var settings = {
    speed: 800
    };

    if (options) {
    $.extend(settings, options);
    }

    function testFunction() {
    $('div').append("Howdy folks
    ");
    }

    timer = setInterval(function() {
    testFunction();
    }, settings.speed);
    };
    })(jQuery);

    This works:

    $('div').colorspan();

    This doesn’t work:

    $('div').colorspan(speed:'100');

    Test Case: http://jsfiddle.net/john_motyl/yETC3/

    #114380
    TheDoc
    Member

    You were *very* close ;)

    http://jsfiddle.net/yETC3/1/

    #114390
    JohnMotylJr
    Participant

    @The Doc = FOR THE WIN!

    Thanks man, i dont know how i forgot that.

    #114392
    TheDoc
    Member

    If JSfiddle ever dies and somebody wants to know, this is all that needed to be changed:

    $(‘div’).colorspan({ speed:’100′ });

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.