arrow-left
All pages
gitbookPowered by GitBook
1 of 1

Loading...

Defer Loading

Call an action immediately once your Wire is first rendered.

You can use the wire:init Directive to execute an action as soon as your component is initially rendered.

circle-check

This can be helpful in cases where you don't want to hold up the entire page load, but want to load some data immediately after the page load.

<div wire:init="loadTasks">
    <ul>
        <cfloop array="#args.tasks#" index="task">
            <li>#task#</li>
        </cfloop>
    </ul>
</div>
component extends="cbwire.models.Component" {

    property name="taskService" inject="TaskService@myapp";
    
    data = {
        "tasks": []
    };
    
    function loadTasks(){
        data.tasks = taskService.asMemento().get();
    }
    
}