thanks for your help! :)

I understand that there's not a standard coding :P

I'll try do my best to code my plugin, and read some other
discussions.

thanks
max

On 29 Dic, 19:54, Balazs Endresz <balazs.endr...@gmail.com> wrote:
> > Which is the right plugin writting way?
>
> Of course, there isn't any :)
> In javascript you can structure your code in almost countless ways.
> For a simple plugin here's what you 
> need:http://www.learningjquery.com/2007/10/a-plugin-development-pattern
> but if you want to write object oriented plugins it's a bit more
> complicated (if you look at my profile or search on the list there are
> some quite long discussion about it) - though if you don't really know
> what is private and public just go for the link above. For a really
> good and short introduction to javascript I'd advise watching Douglas
> Crockford's videos on Yahoo Theatre. Briefly, the scope of the
> variable (or function) will be the function/closure it was declared
> in. This is the key to understand the differencies above.
>
> $myObj.fn.extend = $myObj.extend = $.extend
> I haven't seen this before but it is actually a very smart thing: it
> reuses jquery's extend function, which will work on any object because
> it uses the `this` keyword, so it will be able to extend $myObj too.
> (see here what extend is used 
> for:http://docs.jquery.com/Utilities/jQuery.extend).
> $myObj.fn is most likely a reference to $myObj.prototype but it's not
> indicated in your code above.
>
> Hope I could help a bit, the mailing seems to be dead during the
> holidays :)
>
> On Dec 28, 12:11 pm,Saledan<bastil...@gmail.com> wrote:
>
> > up, please!
>
> > bye
> > max
>
> > On 26 Dic, 12:19,Saledan<bastil...@gmail.com> wrote:
>
> > > Hi,
> > > i'm trying to write a jQuery plugin, i have read some posts, documents
> > > and other plugin code, but i don't understand the right standard to
> > > write a plugin.
> > > I found some patterns...
>
> > > == example 1==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       // do something
> > >     });
> > >   };
>
> > > })(jQuery);
>
> > > == example 2==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       // do something
> > >     });
> > >   };
> > >   // private function
> > >   function functionA () {..do something..};
>
> > > })(jQuery);
>
> > > == example 3==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       // do something
> > >     });
> > >   };
> > >   // Public function?!?
> > >   $.fn.myPlugin.functionA () {..do something..}
>
> > > })(jQuery);
>
> > > == example 4==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       // do something
> > >     });
> > >   };
>
> > >   $.extend(myPlugin.prototype, {
> > >     functionA : function() {..do something..},
> > >     functionB : function() {..do something..}
> > >   }
>
> > > })(jQuery);
>
> > > == example 5==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       // do something
> > >       var functionA = function () {..do something..}
> > >     });
> > >   };
>
> > > })(jQuery);
>
> > > == example 6==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       // do something
> > >     });
> > >   };
> > >   $.fn.extend ({
> > >     functionA : function () {..do something..}
> > >   });
>
> > > })(jQuery);
>
> > > == example 7==
> > > (function($) {
> > >   $.fn.myPlugin = function(o) {
> > >     return this.each(function() {
> > >       new myObj();
> > >     });
> > >   };
>
> > >   $.myObj = function () {..do something..};
> > >   $myObj = $.myObj;
> > >   $myObj.fn.extend = $myObj.extend = $.extend;
> > >   $myObj.fn.extend ({
> > >     functionA: function() {..do something..},
> > >     functionB: function() {..do something..}
> > >   });
> > >   $myObj.extend ({
> > >     functionC: function() {..do something..}
> > >   });
>
> > > })(jQuery);
>
> > > Which is the right plugin writting way?
> > > I think that the last example is well done... but i don't understand
> > > this line $myObj.fn.extend = $myObj.extend = $.extend; and the
> > > differents between $myObj.fn.extend and $myObj.extend .. public or
> > > private function? the first is for public function?
>
> > > Please may you help me?
>
> > > Many thanks
> > > bye
> > > Max

Reply via email to