jeudi 1 juin 2017

How can I access Checkboxes in a dynamically created tr using Jquery (Not delegation)

I have a table in which a tr can by dynamically added. The tr contains checkboxes that signify whether a team member has a certain role - this is defined by having a utilisation greater than 0 for that role. The roles and utilisation are set in a dialog box.The following method is called for each different role type when the dialog box values are saved against the team member.

if (teamMember.designerUtil > 0) {
  $('tr', '#my-table').eq(tableRow).find("#designerCheck").prop("checked",true);
}

What I am trying to achieve is have the checkbox on the tr for the team member that has a role set in the modal check when they have been given the role. The code above works only for the tr that was created when the page loads, NOT for any created dynamically. I have read about event delegation but I don't think there is an event to attach. I just want to check the checkbox using Jquery, not initiate an event.

Image showing dialog box and table with checkboxes




Aucun commentaire:

Enregistrer un commentaire