Hello i just starting to get into JQuery plugins, but i am having some problems understanding the namespace.
Given the example below, when i enter the "submit" function, how do i get prototype instance inside the submit function? like the "var self = this;" in the other function? this in that method refers to the form element.
(function ($, window, document, undefined) {
var PluginPrototype = {
init: function (options, element) {
var self = this;
$(element).find('form').submit(self.submit);
self.otherMethod();
},
submit: function(){
var self = this; // the form element
},
otherMethod: function () {
var self = this; // the prototype
},
}
$.fn.pluginname = function (options) {
return this.each(function () {
var plugin = Object.create(PluginPrototype);
plugin.init(options, this);
$.data(this, 'pluginname', comment);
// Get it by
// $.data($(select)[0], 'comment');
});
};
$.fn.pluginname.Settings = {
};
}(jQuery, window, document));