GarethAtFlignet wrote:
> Here is a sample code snipped. The key points which 'cannot' be
> changed is that the classname must be sourced from a variable and not
> static (same for the parameters).
>
> var widgetName = "Button";
> var widgetParam1 = "I am parameter 1";
> var widgetParam2 = new Array("I am ", "parameter 2");
> eval("var myWidget = new "+widgetName+"(widgetParam1,
> widgetParam2);");
I suppose you could do something like this:
var widget1 = new Object(); // Wherever the widgets come from...
var widget2 = new Object();
[...]
var Widgets = new Object();
Widgets[someWidgetname] = widget1;
Widgets[anotherWidgetname] = widget2;
[...]
var widgetName = "Button";
var widgetParam1 = "I am parameter 1";
var widgetParam2 = new Array("I am ", "parameter 2");
var myWidget = new Widgets[widgetName](widgetParam1, widgetParam2);
(I've never tried anything like that, but I suppose it must
be possible...)
--
Bertilo Wennergren <http://bertilow.com>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---