;(function($) {
var Sanbox = {
init: function(options, elem) {
self = this;
// combine default options and user passing
self.options = $.extend( {}, $.fn.sanbox.options, options );
console.log( this ); // an instance of Sanbox() object the caller
},
greet: function() {
console.log( 'work' );
}
};
// create your sanbox plugin
$.fn.sanbox = function(options) {
return this.each(function() {
var sanbox = Object.create(Sanbox);
sanbox.init(options, this);
})
}
// plugin default options
$.fn.sanbox.options = {
name : 'byer',
age : 24,
address : 'Lorem ipsum dolor sit amet.'
};
})(jQuery);
// use
Any way I can use/access the greet() method outside the jQuery Plugin definition?
And inside the init() method, what 'this' refer to?