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?
Denna fråga har flaggats
1
Besvara
6964
Vyer
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
Njuter du av diskussionen? Läs inte bara, delta också!
Skapa ett konto idag för att ta del av exklusiva funktioner och engagera dig i vår fantastiska community!
Registrera dig| Relaterade inlägg | Svar | Vyer | Verksamhet | |
|---|---|---|---|---|
|
|
2
maj 25
|
11836 | ||
|
|
3
mars 24
|
7521 | ||
|
|
1
jan. 21
|
5210 | ||
|
|
1
juni 18
|
4829 | ||
|
|
2
nov. 25
|
1379 |