Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
5213 Visualizzazioni

I added custom button inside a website form but after clicking it always calls website/form controller and says 'Bad Request'. How I make it call only JS function that I added without going to controller?

Avatar
Abbandona
Risposta migliore

Hi,

In .xml

<button name="my_button" type="object" string="My Button" on_click="my_js_function"/>

js:-

function my_js_function() {
// code for your JavaScript function goes here
}
// add event handler for button click event
document.getElementById('my_button').addEventListener('click', function(event) {
// call JavaScript function
my_js_function();
// prevent default action of button
event.preventDefault();
});

Regards

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
mag 25
9889
3
mar 24
5545
1
gen 21
3552
1
giu 18
3526
0
gen 25
1323