Is there a way to dynamically create a select element using attributes such as select id and select class from a JSON object defined in my controller, without knowing the specific attributes beforehand?
Can this be achieved without resorting to dynamic partials with hardcoded code for each select element?
If I do not have prior knowledge of what attributes are present in the JSON object.
Thank you!
UPDATE:
For example, if the JSON data looks like this:
{ "topology" : [
{ "name": "id", "value":"topology_id" },
{ "name": "class", "value": "topology_class1 topology_class2" },
{ "name": "diasbled", "value": "disabled" }
]
}
I would like to generate the following select tag:
<select id="topology_id" class="topology_class1 topology_class2" disabled="disabled"></select>
Subsequently, if another JSON object contains different attributes, those attributes should populate the select tag accordingly.