Hey everyone,

I'm trying to create an object that will have some properties
predefined, but will allow me to pass in properties to override those
standard props if needed. I'm trying something like:

var myObject = Class.create();

myObject.prototype = {
        initialize: function(element, options) {
                
                this.element = $(element);
                this.name = this.element.id;
                this.options = Object.extend({
                        data: eval(this.name + 'Data')
        }, options || {});
},

What I want is the this.options.data property to default to a JSON
object that has the convention of: id of element + 'Data', so if you
have this object in your javascript you don't have to do anymore work.
If you want to pass in a different object though you can do so like:

new myObject('elementID',{data: myJSONObject})

It works great if no object is passed as an argument, but when I try
to pass a data param through nothing happens. I don't even get an
error. I can pass other things through like:

new myObject('elementID',{foo: myJSONObject})

and I'll be able to alert out myObject.options.foo, it's only when I'm
trying to override my default data property, I run into trouble.

Thanks for any help,
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to