Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
4718 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
mai 25
9511
3
mars 24
5105
1
janv. 21
3174
1
juin 18
3228
0
janv. 25
894