[jQuery] Re: Object-oriented plugins?

2008-11-26 Thread Carpii
On Nov 26, 10:27 pm, ajpiano <[EMAIL PROTECTED]> wrote: > > this is just a pattern i have developed for myself but if anyone has > feedback on it please do share... > Can you show an example of how such a class would be used? Im struggling to understand the benefit of it, although Im sure there

[jQuery] Re: Object-oriented plugins?

2008-11-26 Thread ajpiano
I've been writing a lot of jQuery plugins for internal use that use an OO and prototypal approach. I have a basic class that i use for all plugins that provides some basic methods (like storing the instance in the .data() of the element and fires the internal methods of the subclass, and then i a

[jQuery] Re: Object-oriented plugins?

2008-11-26 Thread Balazs Endresz
I personally use the same approach in the Translate plugin (maybe I should have told you that before :), but with that you don't need the 'new' keyword: $.translate() returns a new object (it's a bit similar to $.ajax or jQuery itself, you don't need 'new' there either). http://code.google.com/p/j

[jQuery] Re: Object-oriented plugins?

2008-11-26 Thread Hector Virgen
I've been thinking about this over the weekend and came up with a way to write class-based plugins while still following the jQuery convention. Maybe someone else has done this before but I couldn't find any documentation on this subject. The idea is to extend the base jQuery object with the javasc

[jQuery] Re: Object-oriented plugins?

2008-11-23 Thread Scott González
Providing the method name as the first parameter is a bit awkward, perhaps looking at the alternatives would help: Add namespaces to jQuery. This isn't very jQuery-like. Example: $ (el).tabs.add(url, label).show(); Add a new jQuery method for every plugin instance method. This pollutes the jQ

[jQuery] Re: Object-oriented plugins?

2008-11-23 Thread Balazs Endresz
> To be honest, this seems a little awkward for me. This means I would have to > write my plugin to check the first parameter to see if it's a string or an > object, and if it's a string I then would have to make a switch to call the > approriate method based on the string value. You don't need a