What’s the difference between these two options:
Option 1:
export function button1_click(event) {
}
Option 2 (inside onReady) :
$w(“#button1”).onClick( (event) => {
})
When should I use option1 and when I should use option2? Aren’t they the same?
Thanks,
The only difference is that when using Option 1 , you need to connect the component to the button1_click() function - this is done in the component’s Properties panel:
Option 2 adds the event handler and it’s connected by definition. No need to connect it via the Properties panel.
Your choice depending on mood and style.
I often use Option 1 when adding an event handler in a Repeater’s onItemReady() event handler.