Reputation: 1076
I need to create an edit button for each data cell in the column and I saw in this tutorial that to start things of I need to add an identifier to the Table Data Cell element ( ): https://www.youtube.com/watch?v=pNxWUfw1J_w, but I have those tds defined in JS:
function refresh_row(row, values) {
var tds = $(row).children('td');
var ii = 0;
$(tds[ii]).html(values.type.name);
ii++;
$(tds[ii]).html(values.description);
ii++;
$(tds[ii]).html(values.company);
ii++;
$(tds[ii]).html(values.place);
ii++;
}
Is there any way to add an identifier like:
id="result-${obj.id}" data-testid="${obj.id}""
to the values.description
data cell elements?
If it makes it any easier, values
is a Python dictionary populated with JSON data similar to the one used in this question: Is transferring JSON data in Django possible without JS / JQuery?
Upvotes: 1
Views: 63
Reputation: 5777
You could use attr('id'...)
and data('testid'...)
to achieve this:
$(tds[ii]).html(values.description).attr('id', 'result-${obj.id}').data('testid', '${obj.id}')
Upvotes: 1