Bind event "change" for select element

2 Answers 112 Views
General Discussions
Marco
Top achievements
Rank 2
Iron
Iron
Marco asked on 19 Dec 2022, 10:06 PM | edited on 19 Dec 2022, 10:09 PM

Please, look at here:

https://dojo.telerik.com/uXaWUMuz

I'm trying to trigger the "change" event of my select.

data-bind="select: onSelect"

But, as seen from the js console,  "select" returns an error and "change" is not supported.

I tried with

data-bind="events: { select: onSelect }"

"Click" works fine  but it not exactly what i want...

Can you help me?

Many thanks ☺

 

2 Answers, 1 is accepted

Sort by
1
Accepted
Paolo
Top achievements
Rank 2
Iron
answered on 20 Dec 2022, 08:24 AM

You should create a variable in your viewModel which holds the current selected value of your <select> tag and bind it appropriately.

After that, it's enough to bind your whole viewModel to "change" events, filtering only those changed fields which you are interested in.

Check out my implementation:

https://dojo.telerik.com/uXaWUMuz/2

Marco
Top achievements
Rank 2
Iron
Iron
commented on 20 Dec 2022, 02:35 PM | edited

Thanks Ipernet! Your solution seems very helpful! ☺
0
Lyuboslav
Telerik team
answered on 20 Dec 2022, 02:20 PM

Hi Emanuele,

Thank you very much for replying in the thread and suggesting a solution.

The described approach seems correct, thus I would suggest Marco follow the suggestion provided in the example. 

Regards,
Lyuboslav
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Marco
Top achievements
Rank 2
Iron
Iron
Answers by
Paolo
Top achievements
Rank 2
Iron
Lyuboslav
Telerik team
Share this question
or