Reputation: 45
Sorry if that question was a bit unclear. Let me try to explain.
I am starting to learn to write jQuery plugins. I have a method of the plugin that is private and is called like so:
var $curPgInf = getPgInf($('#content1_0'));
I don't know if it is any better performance-wise, but it seems cleaner to me (and I'm mostly curious to see if/how it can be done) to be able to call it like this instead:
var $curPgInf = $('#content1_0').getPgInf();
I know that I can use:
$.fn.getPgInf = function(obj) {
// return the page info...
}
but that makes the function public...
Upvotes: 0
Views: 39
Reputation: 150313
jQuery plugin extends the jQuery object, so every function you add to $-jQuery
will be public.
(The fn
property is the prototype of the jQuery object.)
After that short explanation, the answer is, NO, you can't extend jQuery with a private function.
Upvotes: 2