init()
Initialize and create a new instance of Author API to load and interact with the Learnosity authoring interface.
You must use this method in order to initialize Author API and access its methods and events.
The init
method is called from the LearnosityAuthor
factory, and should only be called once per instantiation of the Author API. From there, you can use the returned application instance, referred to as authorApp
throughout the documentation, to access all Author API methods.
Examples
<div id="my-custom-container"></div>
<script>
var initializationOptions = {
// See Initialization for a full list of options
// ...
};
var domSelector = 'my-custom-container';
var callbacks = {
errorListener: function (event) {
console.log("Learnosity Author API error", event);
},
readyListener: function () {
console.log("Learnosity Author API is ready");
}
};
// Instantiate the authorApp. The authoring interface
// will be injected into a container with id="my-custom-container".
var authorApp = LearnosityAuthor.init(
initializationOptions,
domSelector,
callbacks
);
</script>
Arguments
-
domSelector string
Specifies the DOM selector to inject the authoring interface rendered by Author API.
Important An empty container element must be placed on the page with a unique ID where the authoring interface will be rendered.
<!-- On the page, add a <div> container with a unique ID where the authoring interface will be rendered --> <div id="my-authoring-interface-container"></div> <script> // When init() is called, the authoring interface will be injected // into the 'my-authoring-interface-container' container on the page window.LearnosityItems.init( initializationObject, callbacksObject, 'my-authoring-interface-container' ); </script>