I'm creating a dynamic table row. my data source looks like this
data = [
{
"id": 11,
"tests": [{
"id": 2,
"name": "Glucose Level"
},
{
"id": 4,
"name": "Blood Oxygen"
}
],
"carepathway": {
"id": 16,
"name": "General Check-Up",
"slug": "general_check_up",
"dynamic_field": null
}
}
]
This is how I'm creating my table.
$.each(data, function(key, val) {
var tr = $("<tr />");
tr.append($('<td>').append("<p>" + val.carepathway.name + "</p>"))
.append(
$('<td>').append(
$.each(val.tests, function(k, v) {
var $test_controls = $("<div/>", {
"class": "controls"
})
$test_controls.append(
$("<label>", {
"class": "checkbox",
"name": v.name,
"text": v.name,
'id': v.id
}).append(
$("<input>", {
"type": "checkbox",
"value": v.name,
'id': v.id
})
)
)
})
))
$("#patient_care_pathway_table tbody").append(tr);
});
First <td> value coming fine but nothing is coming for the second <td> What I'm doing wrong here?
Second <td> should contain the checkbox with the label, Like this
