Using Save/Submit Buttons With the Items API Inline Mode

This article outlines the Items API's ability to render UI buttons for the save and submit functionality.
 

The Items API exposes Public Methods to perform save and submit operations, which provides freedom to handle these operations and render custom UI as appropriate.

However, it also provides the ability to render a predefined UI for these operations, in case the client did not have a need for customizing the UI for them. To do so, a client needs to simply assign an attribute in the Activity JSON and insert a HTML hook where it wants the button to be rendered.

The save() and submit() operations are only valid when the Items API is initialized in Submit Practice Activities. If the Items API is initialized in local_practice mode, then calling these methods will raise error 10004 instead. To implement these operations in local_practice, see Local Practice Activities for more information.

Key Type Default Description
renderSaveButton boolean false If true, the API will render a Save Button
 

Example

var initOptions = {
...
"config": {
"questions_api_init_options": {
"renderSaveButton": true
}
}
}; 

A HTML node with class "learnosity-save-button" is required for the button to be rendered. The node acts as a placeholder and can be positioned anywhere within the DOM. If the attribute is true and the node is not found, nothing is rendered in the UI and an error event is triggered.

<span class="learnosity-save-button"></span>

Key Type Default Description
renderSubmitButton boolean false If true, the API will render a Submit Button

 

Example

var initOptions = {
...
"config": {
"questions_api_init_options": {
"renderSubmitButton": true
}
}
};

An HTML node with class "learnosity-submit-button" is required for the button to be rendered. The node acts as a placeholder and can be positioned anywhere within the DOM. If the attribute is true and the node is not found, nothing is rendered in the UI and an error event is triggered.

<span class="learnosity-submit-button"></span>

 
Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.