Author API Methods
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
-
initalizationOptions object
See Author API Initialization for a full list of options.
-
domSelector string
Specifies the DOM selector where the authoring interface rendered by Author API is injected.
Important An empty container element must be placed on the page with a unique ID where the authoring interface will be rendered.
Default:
"#learnosity-author"
<!-- Example 1: On the page, add a <div> container with a unique ID where the authoring interface will be rendered, pass to init() along with a `callbacksObject` --> <div id="my-authoring-interface-container"></div> <script> // When init() is called, the authoring interface will be injected // into the container with ID 'my-authoring-interface-container' on the page window.LearnosityAuthor.init( initializationObject, callbacksObject, '#my-authoring-interface-container' ); </script> <!-- Example 2: On the page, add a <div> container with a unique ID where the authoring interface will be rendered, pass to init() but omit `callbacksObject` if it's not required --> <div id="my-authoring-interface-container"></div> <script> window.LearnosityAuthor.init( initializationObject, '#my-authoring-interface-container' ); </script> <!-- Example 3: On the page, add a <div> container with the default ID (so no need to pass `domSelector` to init()) --> <div id="learnosity-author"></div> <script> // When init() is called, the authoring interface will be injected // into the container with ID 'learnosity-author' on the page // Note no string (nor callbacks) are passed here. window.LearnosityAuthor.init( initializationObject ); </script>
-
callbacksObject object
See Author API Initialization Callbacks for a full list of callbacks.
Return value
Type authorApp