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() {

// 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
#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() {


// 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 
For more options, visit this group at 

Reply via email to