Help Center>Foundation Help

SVFormRowInserted

The SVFormRowInserted function is targeted towards repeating elements (i.e. repeating table/repeating groups). The SVFormRowInserted function is called after the insertion of a new row.

Argument

Description

rowContainer

The JQuery object containing the DOM row container

rowNumber

The row number of the newly added row

Code sample

The following code snippet populates the first field in a repeating table with the current row number.

//Create function with the rowContainer and rowNumber arguments

function SVFormRowInserted(rowContainer, rowNumber)

{

//Option 1: Get XPath from Composer. This will restrict values being set to specific table/field

// Must add rowNumber index to XPath (0-based)

var xPath = "/my:myFields/my:Repeating_Table_35/my:Repeating_Content["+(rowNumber-1) + "]/my:field_106

//Option 2: Generate XPath from data-link attribute (JSON format). This will apply to ALL tables

//Get the first binding element

//var firstColumn = rowContainer.find("[data-link]:first");

//Convert JSON notation to XPath notation

//var xPath = "/" + Utils.formatXPathFromBinding(firstColumn.attr("data-link").replace(/\.ws_text/, ''), true);

//Set the value

$form.setValue(xPath, rowNumber);

}