Actions
Last updated
Was this helpful?
Last updated
Was this helpful?
Actions are methods on your that either change the component's or perform some routine, such as updating your database or anything you can dream up in CFML.
Here is a basic example of how to use it:
Some examples of events you can listen for include:
click
wire:click
keydown
wire:keydown
submit
wire:submit
On some elements, such as forms or links, you need to add a .prevent modifier to prevent the browser's default behavior. Otherwise, the browser will cause the page to reload and you will get unintended results.
You can pass parameters to actions such as actionName( arg1, arg2, arg3 ).
The parameter is then passed through to your actions via function arguments.
$refresh
Will re-render the component without firing any action
$set( 'dataproperty', value )
Shortcut to update the value of a property
$toggle( 'dataproperty' )
Shortcut to toggle boolean properties off and on
Consider the example below.
Livewire listens for browser events and invokes actions on your using directives. These directives are used in your HTML and follow the format: wire:[browser event]=[action].
There are a few magic actions already created on your .