diff --git a/packages/actions/docs/06-adding-an-action-to-a-livewire-component.md b/packages/actions/docs/06-adding-an-action-to-a-livewire-component.md index 88449a5e4c..09ec8903d7 100644 --- a/packages/actions/docs/06-adding-an-action-to-a-livewire-component.md +++ b/packages/actions/docs/06-adding-an-action-to-a-livewire-component.md @@ -236,3 +236,56 @@ public function publishAction(): Action Now, when the first action is submitted, the second action will open in its place. The [arguments](#passing-action-arguments) that were originally passed to the first action get passed to the second action, so you can use them to persist data between requests. If the first action is canceled, the second one is not opened. If the second action is canceled, the first one has already run and cannot be cancelled. + +## Programmatically triggering actions + +Sometimes you may need to trigger an action via other means besides a button, link, or key binding, especially when integrating with other JS packages. This can be accomplished with the `mountAction` method. Here is an example of a simple delete + +```PHP +action(function (array $arguments) { + dd('test action called with id: '.$arguments['id']); + }); + } +} + +``` + +And this is how you can trigger that action from within a script block or from a custom HTML element. + +```HTML +
+ + +
+ +@script + +@endscript + +``` + +