Is it Livewire or Alpine?
If Livewire, you can use $wire.set
<div class="border-dashed border-r-2 p-2 shadow-sm" x-on:click="$wire.set('addSearch', 'words here') ">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all,
I am trying to set x-on:click="addSearch = 'words here'" on the input field when the div is clicked. But at the same time i would like the search bar to submit the value. I can set the addSearch = 'words here'" in the search bar when clicking on the div, but I cannot manage to get the type submit to be simulated(eg: After having the word in the search bar, we submit the value to the laravel back end).
//Search Bar
<x-inputs.text name="search" x-model="addSearch" value="{{ $search ?? '' }}" autocomplete="off"></x-inputs.text>
//Div block
<div class="border-dashed border-r-2 p-2 shadow-sm" x-on:click="addSearch = 'words here'">
//Button
<button type="submit" class="button button-primary" ></button>
</div>
Any idea please?
Thanks
Finally!!!
x-on:click="addSearch = 'words here';setTimeout(() => $refs.submit.click(), 3000)"
Please or to participate in this conversation.