2022.2

Table Of Contents
"this"onpage781and"Settingthescopeofascript"onpage373).
l
Theelementsreturnedbyaqueryinthetemplate(see"query()"onpage742).
Examples
ThisscriptretrievestheinnerHTMLofanelementselectedfromasnippet.
var snippet = loadhtml('snippets/snippet.html','#foobar').children();
results.append(snippet);
ThefollowingscriptretrievestheinnerHTMLoftheelementsandthenperformsafind/replace.
var snippet = loadhtml('snippets/snippet.html','#foobar').children();
snippet.find('@firstname@').text('foobar');
results.append(snippet);
clone()
ThisfunctionreturnsacopyofoneHTMLelementorofasetofHTMLelements,whichcanbe:
l
Theelementsthatmatchtheselectorofascript(see"results"onpage844).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage781and"Settingthescopeofascript"onpage373).
l
Theelementsreturnedbyaqueryinthetemplate(see"query()"onpage742).
Seealso:"Dynamicallyaddingsections(cloning)"onpage406.
Toduplicateanexistingtemplateelement,cloneitbeforecallingappend();see"append()"on
page788.
Examples
Thisscriptperformsaniterationovertheelementsintheresults(theelementsthatmatchthe
selectorofthescript).
var row = query("tbody tr", results).clone();
query("tbody", results).append(row);
Thefollowingscriptclonesanexistingtablerowtomatchthenumberofrowsinadetailtable.After-
wardsititeratesovertherowstopopulatethefields.
// Create the number of rows based on the records in the detail table
// We start at 1 so the boilerplate row is used too and there is no need to delete that row
for(var r = 1; r < record.tables['detail'].length; r++) {
results.parent().append(results.clone());
}
// Iterate over the rows and populate them with the data from the accompanying data row
Page 759