getSelectedItems()
Retrieve the contents of the selected Items, including their Questions and Features, in the Item list view.
You would want to use this method so that you can display the Item JSON in your application for validation purposes, for example.
Important
The enable_selection
initialization option must be set to true
for this method to function.
Examples
var selectedItemsPromise = authorApp.getSelectedItems();
selectedItemsPromise
.then(function (response) {
console.log(response);
/* The response object will be similar to:
{
data: {
items: [
{
item: { ... },
questions: { ... },
features: { ... }
},
...
...
]
}
}
*/
})
.catch(function (error) {
console.log('An error occurred');
});
Arguments
None.
Return value
- object
The method returns a Promise which resolves with an array of Item JSON(s) (see itemJson) from the server. An asynchronous call is performed to retreive the selected Items and its related contents.
- boolean
If no Items are selected or if this method is called while not in the Item list view,
false
is returned.
Type definitions
itemJson object
-
features array[widgetObject]Array of Widget objects for Features in the Item.
-
item objectThe settings and contents of the Item.
-
questions array[widgetObject]Array of Widget objects for Questions in the Item.
Related articles
- The
enable_selection
initialization option, which allows authors to select multiple Items in the Item list view. - The
clearSelectedItems()
method, which deselects the Items in the Item list view.