Share via


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)

Arguments

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

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

Return Value

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

Remarks

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.

Example

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.';
    }
}

See Also

Reference

Sys.Application Class

Other Resources

Language Reference