Instead, callback();use .apply()to give it the correct context (otherwise it window), for example:
callback.apply(this);
/ .
, , callback, , options, :
(function($){
$.fn.myPlugin= function(options, callback) {
return this.each(function(){
$(this).click(function(){
callback.apply(this, [options]);
});
});
};
})(jQuery);
:
$('p').myPlugin({
thing: "thing1"
}, function(opts){
alert(opts.thing);
});β
, , , callback() :)