[jQuery] Plugin - internal functions
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=295055113-09052006><FONT face=Arial
color=#0000ff size=2>I think it would depend on whether the function could be
reused in several places. If it is not useful outside the function, then I would
think it should be nested rather than added to $.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=295055113-09052006></SPAN><SPAN
class=295055113-09052006></SPAN><SPAN class=295055113-09052006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com] <B>On Behalf Of </B>ashutosh
bijoor<BR><B>Sent:</B> Tuesday, May 09, 2006 6:06 AM<BR><B>To:</B> jQuery
Discussion.<BR><B>Subject:</B> [jQuery] Plugin - internal
functions<BR></FONT><BR></DIV>
<DIV></DIV>I was just reading about creating jquery plugins, when I noticed the
following comment in the docs:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<P>If you need to write any private methods (ones that the end-coder doesn't
need to see), you can feel free to bind them to the $ object itself, for
example: </P><PRE>$.test = function() {<BR> // Do some internal stuff<BR>};<BR></PRE>
<P>You can then access it in the same manner: </P><PRE>$.test("some stuff");<BR></PRE>
<P>We recommend that you do it this way so that your code doesn't accidentally
overwrite any other functions that the user may be using. </P></BLOCKQUOTE>But
if you see how <SPAN id=site-slogan>Michael has written internal functions in
his json plugin, he defines his internal functions inside the plugin function
itself.<BR>Would this not be the recommended way to write internal functions?
<BR><BR>Regards<BR>Ashutosh<BR></SPAN></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/