Skip to content

Instantly share code, notes, and snippets.

@jarrodbell
Created April 3, 2012 01:42
Show Gist options
  • Select an option

  • Save jarrodbell/2288665 to your computer and use it in GitHub Desktop.

Select an option

Save jarrodbell/2288665 to your computer and use it in GitHub Desktop.
CommandFusion: JavaScript list population example
function populateList (listJoin, elements) {
CF.log("Populating list");
// Clear the list
CF.listRemove(listJoin);
// Create an array to fill with list contents
var newContents = [];
// Avoid using Array.forEach() method as it uses callbacks to access the data, which means code after the forEach loop will be executed before the loop finishes.
for (var i=0; i<elements.length; i++) {
newContents.push({s1: element.textlabel, s2: element.filename});
}
// Push the array to the list in a single call
// Much more efficient than many CF.listAdd calls within a loop.
CF.listAdd(listJoin, newContents);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment