Is there a way to determine when a user clicked on a URL (TextEntry)

Hey there. I would like to know if I can somehow determine if the user clicked on the URL when using a TextEntry::make()->url()
6 Replies
Dennis Koch
Dennis Koch2w ago
What are you trying to do? You could attach a JavaScript event listener.
Merdin
MerdinOP2w ago
I fixed it using a header action for now but I want it to look like text in infolist and then let the user click on it. After the user has clicked on it I want to save a record in the database.
Dennis Koch
Dennis Koch2w ago
So something like wire:click="saveRecord" and a Livewire method?
Merdin
MerdinOP2w ago
Maybe that could work, will try it !
Matthew
Matthew2w ago
If you are encouraging user to click, then the suffixAction works well in infolists.
Merdin
MerdinOP2w ago
Thanks for your response. Will check it. I solved it now by using an action modal, but how can I make sure the modal gets closed after confirmation button is pressed:
TextEntry::make('meeting_url')
->label('Link naar de les')
->formatStateUsing(fn (Lecture $record) => $record->showMeetingURL() ? 'Klik hier om deel te nemen aan de les' : 'Nog niet beschikbaar')
->color(fn (Lecture $record) => $record->showMeetingURL() ? 'info' : 'gray')
->disabled(fn (Lecture $record) => !$record->showMeetingURL())
->action(
Action::make('recordAttendance')
->label('Voordat je deelneemt aan de les...')
->requiresConfirmation()
->modalHeading('Voordat je deelneemt aan de les...')
->modalDescription('Je gaat akkoord met de regels en gebruikt jouw initialen bij het deelnemen aan de les (in verband met privacy).')
->modalSubmitAction(
function (Lecture $record) {
if ($record->showMeetingURL()) {
$record->attended();
}
}
)
->modalSubmitActionLabel('Naar de les')
->successRedirectUrl(fn (Lecture $record) => $record->meeting_url ?? null)
->openUrlInNewTab()
),
TextEntry::make('meeting_url')
->label('Link naar de les')
->formatStateUsing(fn (Lecture $record) => $record->showMeetingURL() ? 'Klik hier om deel te nemen aan de les' : 'Nog niet beschikbaar')
->color(fn (Lecture $record) => $record->showMeetingURL() ? 'info' : 'gray')
->disabled(fn (Lecture $record) => !$record->showMeetingURL())
->action(
Action::make('recordAttendance')
->label('Voordat je deelneemt aan de les...')
->requiresConfirmation()
->modalHeading('Voordat je deelneemt aan de les...')
->modalDescription('Je gaat akkoord met de regels en gebruikt jouw initialen bij het deelnemen aan de les (in verband met privacy).')
->modalSubmitAction(
function (Lecture $record) {
if ($record->showMeetingURL()) {
$record->attended();
}
}
)
->modalSubmitActionLabel('Naar de les')
->successRedirectUrl(fn (Lecture $record) => $record->meeting_url ?? null)
->openUrlInNewTab()
),

Did you find this page helpful?