Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > JavaScript API > RunnerPage object > Methods

JavaScript API: RunnerPage object > findItem(itemId, recordId)

Scroll Prev Next More

 

Returns the jQuery object representing the page element. Use this function when you need to apply code to one of the page elements.

Syntax

findItem( itemId, recordId );

Arguments

itemId

the element ID. You can use this method only with the items (elements) that have an ID. Learn how to get it in the Inserting button article.

recordId

an optional {integer}. A unique identifier of a record in a data grid on the List page.

Note: use the recordId() function in the GridRow object to obtain this parameter.

Return value

Returns the jQuery object representing the page element.

Examples

Example 1

 

// set the text of a 'total' element
pageObj.findItem( 'total' ).text( '42' );

 

Example 2

 

// set the background of a  'simple_grid_field' element
pageObj.findItem( 'simple_grid_field' ).css( 'background', 'red' );

 

Note: use the recordId parameter for the data grid elements on the List page.

 

Example 3

 

For this example, let's say you want a field in the grid to change its background when a user clicks the row.

 

Proceed to the Choose Pages screen -> Click actions -> Run AJAX snippet and add this code to the Client before event:

 

pageObj.findItem( 'simple_grid_field', row.id() ).css( 'background', 'yellow' );

 

Note: If you omit the recordId parameter, the background is applied to the field value in all grid rows instead.

 

Example 4

 

// change the background of the first record's custom button
var allRecords = pageObj.getAllRecords();
pageObj.findItem( 'custom_button', allRecords[0].recordId() ).find('a').css( 'background', 'red' );

See also:

JavaScript API: RunnerPage object > getAllRecords()

Grid Row JavaScript API: recordId()

Tri-part events

Page designer: Insert custom button

Page Designer

Choose pages screen

Click actions

Show order total on the Edit page as the details table is updated

JavaScript API: RunnerPage object

JavaScript API