1

Noob question here, my basic setup looks like this:

(function($) {
    $.fn.imageSlider = function(options) {
        var defaults = {
            columns: 3,
            imgHeight: 50,
            imgWidth: 75,
            jsonScript: '',
            jsonData: {},
            onComplete: $.noop  // I want a user supplied method here
        };

        var options = $.extend(defaults, options);

        // Exec plugin here

        if($.isFunction(options.onComplete)) {
            // call user provided method
            options.onComplete.call();
        }
})(jQuery)

plugin call

 $('#gallery').imageSlider({
    columns: 6,
    jsonScript: './scripts/galley.php?id=1'
 });

The plugin works fin but will never call the user supplied onComplete function

What do I need to do to get the onComplete method to work?

1 Answer 1

1

One issue that I can immediately see is that you're not properly closing your function definition.

(function($) {
  $.fn.imageSlider = function(options) {

    // ...setup options and code...

  }; // <-- missing this
})(jQuery);

Other than that, everything looks to be working fine: http://jsfiddle.net/y4rkS/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it's always the little stuff that kills me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.