Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
4904 Vistas

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
Mejor respuesta

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
Publicaciones relacionadas Respuestas Vistas Actividad
2
may 25
9670
3
mar 24
5273
1
ene 21
3329
1
jun 18
3336
0
ene 25
1051