I have an application which uses backbone js and jquery. I need to generate templates dynamically based on what response i get from the server. The scenario is like this… I have a dropdown of templates which I can choose, after I select any template from the dropdown, an api is called for that template which provides me with a structure like this
items:[
{
"vars":
{
"name":
{
"required": false,
"default": "abc"
},
"address":
{
"required": false,
"default": "xyz"
}
}
"tables": {}
}]
So how can I create dynamic form elements using this kind of server response?
You could use the backbone-forms plugin, and map your server response to a form object. Something like:
That’s just a simple, untested example. Check out the
backbone-formsdocumentation, and see if it can do what you need.