Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
4875 Visninger

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
Kassér
Bedste svar

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
Kassér
Related Posts Besvarelser Visninger Aktivitet
2
maj 25
9649
3
mar. 24
5254
1
jan. 21
3303
1
jun. 18
3313
0
jan. 25
1017