JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › General Discussions › smart form controlType button add event handler
Hi,
In a smart form, when I add controlType: “button” what is the way to assign a custom event handler?
{ controlType: "button", label: <code>Run</code>, },
I thought this would do it, perhaps controlType: button needs to be treated differently?
controlType: button
const smartButton = document.querySelector('smart-button'); smartButton.addEventListener('click ', function (event) { console.log('hello world'); });
Any clues?
You have done it correctly but have a space in the event name – ‘click ‘. It should be only ‘click’. Try it and the problem must be fixed
Best Regards, Svetoslav Borislavov
Smart UI Team https://www.htmlelements.com/
Hi Svetoslav,
Ok yeah sorry for bothering you about something so small.
Thanks.