Reputation: 24069
I'm trying to clone my template (this is just a tr), then inside the template find a td (this.titleRow) then add text to it.
The problem I have is that the below clones the template, finds the table row, inserts the text but as I have used find, only the title row td is appended from the clone, other td's are not.
How can I do this but keep the command chained?
$(this.tBody).append(this.template.clone().find(this.titleRow).text('John Smith');
Upvotes: 0
Views: 48
Reputation: 93601
You can chain them as a single line if you use appendTo
(instead of append
) as it retains the cloned object as the return value:
this.template.clone().appendTo(this.tBody).find(this.titleRow).text('John Smith');
Upvotes: 1