Action Notify from onClick
I want to copy the content of a input field. And it works, but i want to notify it. The dispatch is not working.
Maybe i'm over complicating it.
TextInput::make("sis")
->label("SIS")
->columnSpan(3)
->required()
->suffixAction(
Action::make("copy")
->icon("heroicon-m-clipboard-document")
->tooltip("Copiar")
->extraAttributes([
"x-on:click" => new \Illuminate\Support\HtmlString("
const wrapper = \$el.closest('.fi-input-wrp');
const input = wrapper?.querySelector('.fi-input');
if (input) {
navigator.clipboard.writeText(input.value);
\$dispatch('notify', { type: 'success', message: 'Copiat!' });
} else {
console.log('Input not found');
}
"),
])
)
TextInput::make("sis")
->label("SIS")
->columnSpan(3)
->required()
->suffixAction(
Action::make("copy")
->icon("heroicon-m-clipboard-document")
->tooltip("Copiar")
->extraAttributes([
"x-on:click" => new \Illuminate\Support\HtmlString("
const wrapper = \$el.closest('.fi-input-wrp');
const input = wrapper?.querySelector('.fi-input');
if (input) {
navigator.clipboard.writeText(input.value);
\$dispatch('notify', { type: 'success', message: 'Copiat!' });
} else {
console.log('Input not found');
}
"),
])
)
0 Replies