I currently have a "new element form" for my application. I used mustacheJS for this template. there are some fields that need data from the database sent via ajax. for example, in a specific selection window.
<select name="customerOrder"> {{#order}} <option value="{{id}}">{{itemName}}</option> {{/order}} </select>
The data to fill these items will look like this:
{ "order": [ { "id":1, "itemName":"Meat Lover Pizza" }, //and so on... ] }
It works fine until I create an editing form, where, in addition to the form data, in order to fill in the selection fields and check boxes, now I have to mark the form elements as selected. but...
element data is retrieved on another ajax call, hence another JSON object. I can’t necessarily merge, because the data can be of different structures. I could try this approach , but it meant that the form data and the element data would be “one” - I do not want this. I want a clear separation of material data and intangible data
element data looks like this basically, but can be nested somewhere in a JSON object:
{ "customer":"mario", "order": 1 --> this item i want selected in the form //and so on... }
if there was only some way to create the form, then fill out and mark it without problems, continuing to use JS mustache. I don’t want to hardcode the data with the corresponding form fields.
I heard about rendering rendering and partial data, but I don’t see how I will use them for this.