When the init plugin has this ...
if( !data ) { $.extend(s, defaults, options); var YoPlugin = $('<div />', { text : $this.attr('title') }); $(this).data('YoPlugin', { target : $this, myInternalFunction: myInternalFunction, settings : $.extend({}, s), YoPlugin : YoPlugin }); data = $this.data('YoPlugin'); }
You can open internal functions, as myInternalFunction has demonstrated. How to get into an object from an event called $ ('body') will exit 'this' as a body, so ...
var multiSel = $('.YoPlugin'); var singleSel = multiSel[0]; //or other way to select the singleton or specific plugin enhanced target var pluginDataObj = $(singleSel).data('YoPlugin'); var func = pluginDataObj['myInternalFunction']; func();
I believe that adding a link as an external plugin link is better i.e. like init: declared in the plugin or similar routes via $ .fn.YoPlugin.myInternalFunction
In any case, this set of fragments provides R&D night to explore and help understand what lir bir betta is.
Also, you definitely need to read everything that you can absorb here ...
http://alexsexton.com/blog/2010/02/using-inheritance-patterns-to-organize-large-jquery-applications/
source share