You don't seem to be actually creating an instance of myPlugin, instead you're trying to access the methods statically which may or may not be what you're after.
I find it better to create an instance of my Plugin object for each time the plugin is used. An example:
!function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(root.jQuery);
}
}(this, function($) {
'use strict';
var defaults = {
};
var Plugin = function(element, options) {
this.element = element;
this.options = options;
};
Plugin.prototype = {
constructor: Plugin,
someMethod: function() {
}
}
// Create the jQuery plugin
$.fn.plugin = function(options) {
options = $.extend(true, {}, defaults, options);
return this.each(function() {
var $this = $(this);
$this.data('plugin', new Plugin($this, options));
});
};
// Expose defaults and Constructor
$.fn.plugin.defaults = defaults;
$.fn.plugin.Plugin = Plugin;
});
From here - https://gist.github.com/simonsmith/4353587
Now you could use the plugin like this:
require(['jquery', 'jquery.plugin'], function($) {
$('.test li').plugin({
test: 'option1',
test2: 'option2'
});
});
An instance of the object is saved in a data property, so it can always be accessed. Herotabs uses this technique:
var instance = $('.tabs').herotabs().data('herotabs');
instance.nextTab();