CBWIRE
InstallSource CodeIssuesSupport
v2.x
v2.x
  • Introduction
  • Release History
    • What's New With 2.2
    • What's New With 2.1
    • What's New With 2.0
  • Getting Started
  • Examples
  • Essentials
    • Configuration
    • Wires
    • Data Properties
    • Computed Properties
      • Computed Properties ( Proxied )
    • Actions
    • Templates
    • Events & Listeners
    • Wire Lifecycle
    • JavaScript
    • Testing
  • Wire Features
    • Validation
    • File Uploads
    • Query String
    • Redirecting
    • Dependency Injection
  • Template Features
    • Directives
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Defer Loading
    • Dirty State
  • Integrations
    • ContentBox CMS
    • Turbo
    • AlpineJS
    • Inline Scripts
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Template Features

Defer Loading

Call an action immediately once your Wire is first rendered.

PreviousOffline StateNextDirty State

Last updated 2 years ago

Was this helpful?

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

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();
    }
    
}
Directive