跳至内容
菜单
此问题已终结
1 回复
4979 查看

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?

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
2
5月 25
9707
3
3月 24
5333
1
1月 21
3387
1
6月 18
3366
0
1月 25
1103