#how to call Dialog::alert when click a button

1 messages · Page 1 of 1 (latest)

lyric gyro
#

I want to call Dialog::alert to ask the user logout or not from a button on layout

light badge
#

If you're using Livewire you can create a function in the Livewire class. If you're using Inertia and VueJS I've found I have to create a new endpoint for it. I've actually moved to LiveWire for all my NativePHP Mobile apps

lyric gyro
light badge
#

Yeah, you'd need to use ajax via JavaScript

lyric gyro
#

nice, thanks for your help.

light badge
lyric gyro
#

ok, i will try it

lyric gyro
#

@light badge I tried to listen the Dialog event in js with
@use(Native\Mobile\Events\Alert\ButtonPressed)

<script>
Native.on(@js(ButtonPressed::class), (index, label) => {
alert(You pressed button ${index}: ${label})
})
</script>
but there's no any alert after I press button on Dialog, and i debug in js code the typeof Native = undefined

#

I don't see any suggestion in nativephp document for this

#

can you help me see it please ? thanks

#

and I still got the event via a listener in php code