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

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.

  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 = queue.data(‘object’);
       var selectedItems = list.getSelectedItems();
    }