You can run an once your component is rendered in the browser using wire:init. This can be helpful when you don't want to hold up loading the entire page but want to load some data immediately after the page loads.
The need for wire:init has largely been replaced by CBWIRE's , but still exists and can be used if you prefer.
// ./wires/MyComponent.cfc
component extends="cbwire.models.Component" {
data = {
"loaded": false
};
function loadData() {
sleep( 2000 ); // pretend this takes a while
data.loaded = true;
}
}
<!--- ./wires/mycomponent.cfm --->
<div wire:init="loadData">
<cfif loaded>
<div>Data is now loaded.</div>
<cfelse>
<div>Loading...</div>
</cfif>
</div>