I have this strange error, I can't access the public method from my plugin. What is wrong here? I use jQuery 1.10.2.
Uncaught TypeError: Cannot call method 'tabsClick' of undefined
Here is my plugin:
;(function ( $ ) {
$.fn.smk_Toolkit_Tabs = function( options ) {
// Defaults
var settings = $.extend({
something: '.my_class',
}, options );
// Reffer to current instance
var plugin = this;
//"Constructor"
var init = function() {
//...
}
// My public method
this.tabsClick = function() {
//...
}
//"Constructor" init
init();
}
}( jQuery ));
Here is how I try to access the public method:
var tkp = $('.smk_toolkit_plugin_container').smk_Toolkit_Tabs();
tkp.tabsClick();
You should add return this;
before the end of $.fn.smk_Toolkit_Tabs
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.