setSafeToUnload - Methods - Author API

Author API Methods


Updates the internal status of the specified view to override its status indicating whether it has any unsaved changes.

You would want to use this method so that you can update the specified view's state when saving Items externally in your own application.


// Update the saveable state of the current Item to true
var hasUpdatedStatus = authorApp.setSafeToUnload('item_edit');

// Update the saveable state of the current Item to false, indicating there are unsaved changes
var hasUpdatedStatus = authorApp.setSafeToUnload('item_edit', false);


  • componentName string

    The name of the component. Supported component names are:

    • "item_edit"

  • isSafe boolean

    If true or omitted, the specified componentName state is marked as safe to unload. This is necessary if saving Items is done externally.

    If false, the specified componentName state is marked as not safe to unload.

    Default: true

Return value

Type boolean

Returns true if the method call succeeded, and false otherwise.


When creating a new Item, it is initially safe to unload until a change is made by the author.

When creating a new Activity, it is initially unsafe to unload, which means the author must save the Activity or this method can be called to allow an empty Activity to be saved.

Related articles

  • The disable_onbeforeunload initialization option, which controls whether Author API will ignore the default browser behavior for showing an unsaved changes warning.
  • The safeToUnload() method, which checks if the current Item or Activity being edited has any unsaved changes.
Was this article helpful?

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