Noob question here, my basic setup looks like this:
(function($) {
$.fn.imageSlider = function(options) {
var defaults = {
columns: 3,
im开发者_开发技巧gHeight: 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?
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/
精彩评论