Skip to Content
Menú
This question has been flagged
1 Respondre
4632 Vistes

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
Descartar
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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de maig 25
9463
3
de març 24
5036
1
de gen. 21
3133
1
de juny 18
3202
0
de gen. 25
831