How do I obtain an existing List component on the page via the Javascript API

  • 1
  • Question
  • Updated 4 years ago
  • Answered
  • (Edited)
I have a queue on my page (a List), and I need to be able to programmatically access its selected item(s) from JavaScript. I see that in the docs for the List object there is a method called getSelectedItems that gives me the selected items.

My problem is I do not know how to obtain the List instance for my particular queue on the page.
Photo of Hamza Tayeb

Hamza Tayeb

  • 278 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,784 Points 50k badge 2x thumb
1. Give your Queue component a Unique Id, e.g. "MyQueue", from the Page Composer.
2. From JavaScript, do this: 

var queue = skuid.$('#MyQueue');
if (queue && queue.length) {
   var list ='object');
   var selectedItems = list.getSelectedItems();