VIDesignz
VIDesignz

Reputation: 4783

Understanding the availability of JQuery Plugin Functions

I am writing a JQuery plugin and all is well so far...Though I have a question that I can not seem to find an answer too.

First, lets say this is the plugin skeleton

(function ($) {

 var outterFunction = function () {};

     $.fn.cssLive = function (getTargets, getStyles) {
         /// Some Stuff
         var innerFunction = function () {};
     }

}(jQuery));

My Questions are as follows...

  1. Are either innerFunction or outterFunction available globally?
  2. Should outterFunction be declared within $.fn.cssLive if I do not need it to be available globally?
  3. Lastly, if outterFunction requires a variable to be set by a developer using my plugin, would I be extending $.fn.cssLive? and if so, how?

My plugin is quite large as of now and it seems most all of my functions are in the realm of the outterFunction, turns out I am only using the $.fn.cssLive to get two parameters. Is this standard or do most plugins have all the functions inside of the main plugin function.

I will be here to answer any questions or go back and forth if needed.

Thank you in advance!

Upvotes: 0

Views: 42

Answers (1)

eXecute
eXecute

Reputation: 176

1) no 2) it depends what it does, but probably to introduce a tighter scope 3) no it would not be extending it, but I'm not sure if that is what you're asking

Upvotes: 1

Related Questions