Export (0) Print
Expand All

Sys.Application.findComponent Method

Returns the specified Component object. This member is static and can be invoked without creating an instance of the class.

var o = Sys.Application.findComponent(id, parent)

id

A string that contains the ID of the component to find.

parent

(Optional) The component or element that contains the component to find.

A Component object that contains the component requested by ID, if found; otherwise, null.

Use the findComponent method to get a reference to a Component object that has been registered with the application through the addComponent method. If parent is not specified, the search is limited to top-level components. If parent represents a Component object, the search is limited to children of the specified component. If parent is a DOM element, the search is limited to child components of the specified element.

The findComponent method can also be invoked by using the $find shortcut method.

The following example uses the findComponent method to check whether a custom component exists and to notify the user if it is missing.

function checkComponent() {
    if (!($find('MyComponent', div1))) {
        div1.innerHTML = 'MyComponent is not available.';
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft