I am currently working on a visual builder that utilizes different views for each component. Each view is defined as shown below:
$(function() {
var parallaxView = new Backbone.view.extend({
....
});
var parallaxView = new Backbone.view.extend({
....
});
});
As I progress, I find myself needing to create a new object view from the stored name of the view in an object.
name
My query is whether it is possible to create an object using the value of 'name' as the class name, similar to creating a new class.
var myView = new name(param1, param2);
instead of having to use a switch statement like this:
switch (name) {
case 1:
....
}
I have attempted to do this:
var myView = new name(param1, param2);
and understand why it does not work. Is there any alternative way to create an object in a similar manner?