thanks guys for you answer but I know how to use $.each in OO context... I would like to understand why jQuery works in this way..
What are the advantage using this inside closure instead of using a temp arguments like the index? I see only disadvantage... I also created a plugin (http://code.google.com/p/jquerycallback/) to manage callback using OO but this remain one of the (few) aspects of jQuery I don't like and I would like to get a reason :) Also... Thinking about OOP... are you really sure that jQuery isn't a OO library (or framework as you prefer)? Two considerations about this relationship between jQuery and OOP: - jQuery selectors are a "strange" way to construct an object, an alternative constructor starting from a dollar sign and not with "new" keyword ( var divs = $("div") should be written as var divs = new jQuery("div") ) - jQuery function (events, attributes, traversing, ecc...) are a lot of methods of jQuery object... they aren't simple namespaced function in a functional paradigm. (alternative) constructor + a lot of methods = object oriented programming why not? I hope to get some reply ;) On Fri, 2009-08-07 at 07:37 -0700, aHeckman wrote: > @ludovic, javascript IS an object oriented language. There is no need > for simulation. It's just a different type of oop than classical. > > function Person (name) { > this.name = name || 'Nobody'; > } > Person.prototype = { > sayName: function () { > alert('Hi my name is ' + this.name); > } > }; > var ludovic = new Person('ludovic') > > On Aug 7, 8:13 am, ludovic <ludothebe...@gmail.com> wrote: > > If you want to keep you function's context, you can still do > > > > $('div').each( function() { > > Context.myFunction( this ); > > > > } ); > > > > Anyway, I'm not sure it's a good idea to try to simulate object > > oriented syntax with javascript. > > It isn't an object oriented language and trying to make a language in > > a foreign paradigm is always heavy. > > But it is a personal opinion... > > > > --- > > Ludovic > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---