Skip to Content
Menu
This question has been flagged
1 Atsakyti
5211 Rodiniai

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?

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
geg. 25
9886
3
kov. 24
5543
1
saus. 21
3550
1
birž. 18
3526
0
saus. 25
1321