p-on
is used to run python code when a specific event trigger.
You can use all events available in the DOM listed here : https://www.w3schools.com/tags/ref_eventattributes.asp
For example if you want to run an function on a click event just use p-on:click="..."
and put your function call inside.
Shorthand syntax
Instead of writing p-on:click="..."
you can write @click="..."
.
Passing events as parameter
Sometimes you need data from an event, in this example we will change the scale of Bob thanks to a range input.
To send the input value to update_scale
we just have to write event.target.value
.
The event is accessible like in JS, it’s really the same thing.