Newer Version Available

This content describes an older version of this product. View Latest

Modifying Components from External JavaScript

You can modify component state outside an event handler and trigger re-rendering of the component. This is particularly useful if you use window.setTimeout() in your event handlers to execute some logic after a time delay.

1swfobject.registerObject("clippy.codeblock-0", "9");window.setTimeout(function () {
2    $A.run(function() {
3        cmp.set("v.visible", true);
4    });
5}, 5000);

This code sets the visible attribute on a component to true after a five-second delay. Use $A.run() to modify a component outside an event handler and trigger re-rendering of the component by the framework.