Seamlessly connect between the front-end and your server back-end using JavaScript and CFML.

Lifecycle Hooks

CBWIRE gives you the opportunity to execute JavaScript during various events.



Called when a Wire has been initialized on the page by Livewire


Called when Livewire initializes an individual element


Called before Livewire updates an element during its DOM-diffing cycle after a network roundtrip


Called after Livewire updates an element during its DOM-diffing cycle after a network roundtrip


Called after Livewire removes an element during its DOM-diffing cycle


Called when a Livewire update triggers a message sent to the server via AJAX


Called if the message send fails for some reason


Called when a message has finished its roudtrip, but before Livewire updates the DOM


Called after Livewire processes all side effects (including DOM-diffing) from a message

    document.addEventListener("DOMContentLoaded", () => {
        cbwire.hook('component.initialized', (wire) => {})
        cbwire.hook('element.initialized', (el, wire) => {})
        cbwire.hook('element.updating', (fromEl, toEl, wire) => {})
        cbwire.hook('element.updated', (el, wire) => {})
        cbwire.hook('element.removed', (el, wire) => {})
        cbwire.hook('message.sent', (message, wire) => {})
        cbwire.hook('message.failed', (message, wire) => {})
        cbwire.hook('message.received', (message, wire) => {})
        cbwire.hook('message.processed', (message, wire) => {})

Interacting With Wires

You can interact with your Wires, calling Actions, setting Data Properties, and more, using cbwire.find from within your Wire Template. Once you have a reference to the Wire, you can interact with it using the methods below.

    document.addEventListener("livewire:load", function() {
        var thisWire = cbwire.find('#args._id#'); // args._id contains the id of our wire
        var count = thisWire.count; // gets the value of a data property called 'count'   
        thisWire.count = 5; // updates the values of a data property
        thisWire.increment(); // calls the increment action on our wire
        thisWire.addTask( 'someTask' ); // calls the addTask action and passes parameters 
        'increment' ); // same as increment call above 
        // On someEvent, console log
        thisWire.on( 'someEvent', function() {
            console.log('Got someEvent');
        } );  
        thisWire.emit('someEvent', 'foo', 'bar'); // emits someEvent and pass parameters
    } );

Last updated