1

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?

1 Answer 1

1

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}')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.