JavaScript

listObj.persistToStorage Method

Syntax

listObj.persistToStorage(obj);

Arguments

objJSON Object

Internal use only. If using to persist data to a List, pass an empty object: listObj.persistToStorage({});

Description

Manually persists data in a List control to Local Storage or the device's File System.

Discussion

The persistToStorage() method is used to persist a List control's data to local storage. This method is typically used when adding multiple rows to a List using the listObj.addTableRow Method for a List that persists data to the File System in a Cordova application. For example:

//persist multiple rows in a loop
var listObj = {dialog.object}.getControl('list1');

if (listObj) {
    //suspend list persisting
    listObj.suspendPersist = true;

    //execute the .addTableRow() method in a loop

    //turn list persisting back on
    listObj.suspendPersist = false;

    //persist the list (passing in an empty object to the .persistToStorage() method.
    listObj.persistToStorage({});
}

See Also