I'm at a loss here. I have this class I've created that takes arguments in object form:
new Widget('id_of_element', { option1: 'foo', option2: 'bar' });
However, the second argument isn't being seen as a hash, but as an object, so I can't apply default settings to if one is not set:
initialize: function (element, options) {
this.options = $H({ option1: 'something', option2: 'else', option3: 'hello', option4: 100 }).update(options);
}
I need the vales from the argument 'options' to be converted into a Hash, so I can use the update() function. I can't find anything in the Prototype framework that will cast an object as a Hash.
What's strange is, on this.options.inspect(), all the correct values show up, but when I call it:
alert(this.options.option1);
// or
alert(this.options['option1']);
... they come back as undefined. Why would the Hash#inspect method find these values, but are still undefined? Am I missing some substantial understanding of some type?