If I only need one of something, I go with an object, otherwise if I
need more then one I go with a class-like structure.. though I don't
use Prototypes Class method, so I'll let someone that does answer that
part of the question.

Josh Powell

On May 11, 1:44 pm, louis w <louiswa...@gmail.com> wrote:
> I have always set up my Javascript using objects like below:
>
> if (!FooBar_Old) var FooBar_Old = {};
> FooBar_Old.UI = {
>
>         test_str : 'it works'
>
>         , test: function() {
>                 console.log(this.test_str);
>         }
>
> };
>
> // FooBar_Old.UI.test();
>
> However recently I have been wanting to convert these to real classes
> to take advantage of the initialize constructor. I took a first pass
> at this, and can't get it working.
>
> This post is two questions:
> #1 Which method do you use in your javascript programming Objects or
> Classes?
> #2 What am I doing wrong with my class declaration below?
>
> // Class Based (Doesn't work)
>
> if (!FooBar) var FooBar = {};
> FooBar.UI = new Class.create({
>
>         test_str : 'it works'
>
>         , initialize: function(options) {
>                 // Whatever
>         }
>
>         , test: function() {
>                 console.log(this.test_str);
>         }
>
> });
>
> // FooBar.UI.test();
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to