Share via


Ewa.EwaControl.add_applicationReady(function)

Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013

In this article
Return Value
Remarks
Example
Applies To

Subscribes an event handler to the applicationReady event.

Ewa.EwaControl.add_applicationReady(function);

Parameters

function

The event handler to subscribe to the event.

Return Value

None.

Remarks

The EwaControl.add_applicationReady method is a static method of the EwaControl object that subscribes an event handler to the applicationReady event. The applicationReady event is raised when all Excel Web Access Web Parts on the page are completely loaded, which indicates that the object model is available for use.

The event handler for the PageLoad event is typically the location to subscribe an event handler for the applicationReady event and the event handler for the applicationReady event is the typical location to get a reference to an Excel Web Access Web Part.

Example

The following code example gets a reference to an Excel Web Access Web Part in the event handler for the applicationReady event. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.

<script type="text/javascript">
var ewa = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOmPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 
}

// Add event handler for applicationReady event.
function ewaOnPageLoad()
{
    if (typeof (Ewa) != "undefined")
    {
        Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
    }
    else
    {
        alert("Error - the EWA JS is not loaded.");
    }
    // ...
}

function ewaApplicationReady()
{
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);
    // ...
}
</script>

Applies To

Ewa.EwaControl Object

See also

Reference

Ewa.EwaControl.remove_applicationReady(function)

Concepts

Ewa.EwaControl Methods

Ewa namespace