This is a migrated thread and some comments may be shown as answers.

Adding (standard) keyup event handler to TextBox

5 Answers 2497 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Mikkel
Top achievements
Rank 1
Mikkel asked on 20 Jan 2021, 12:05 PM

It seems that your TextBox control/widget only has the change event handler, so I would like to know how to (natively) extend the TextBox widget adding identical functionality for eg. keyup, keydown etc.

The pattern I'm asking about is this:

kendo.ui.TextBox.extend({ ?? })

So that I can use the event handler in both initialization and after:

$("#myTextBox").kendoTextBox({
    label: "Name",
    value: "Hello World!",
    change: function() { alert("Changed!"); },
    keyup: function() { alert("KeyUp!"); },
});

- AND -

$("#myTextBox").data("kendoTextBox").bind("keyup", function(e) { alert("KeyUp!"); });

I know that I could simply do something like below, but I need to be able to do it on initialization - and I don't think it is as clean as extending the generic way.

$("#myTextBox").bind("keyup", function(e) { alert("KeyUp!"); })

5 Answers, 1 is accepted

Sort by
1
Georgi Denchev
Telerik team
answered on 22 Jan 2021, 11:59 AM

Hi Mikkel,

I believe the Custom Widgets documentation is what you are looking for. Generally speaking it's better to extend the existing functionality by creating your own widget and add the additional methods/events in it.

Here is a dojo example on how to add a keyup event.

Let me know if you have any questions

Best Regards,
Georgi Denchev
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/.

0
Mikkel
Top achievements
Rank 1
answered on 22 Jan 2021, 12:22 PM

Thank you for your suggestion, I see that this approach would work.

However, for several reasons, I would prefer to extend the standard TextBox - is that possible, and if so - how?

Ultimately - is it possible to request new features for your TextBox control?

I realize that it is a fairly new control, but it has a very limited set of features and events, so I think many developers would agree that adding the default event handlers (keyup, keydown, focus, lostfocus etc.) would be appreciated.

Thanks again.

0
Georgi Denchev
Telerik team
answered on 25 Jan 2021, 09:04 AM

Hi Mikkel,

You can request new features or report bugs through our Feedback Portal where other people can vote for the suggestions. Requests with high demand get implemented sooner.

You can check the following StackOverflow answer which provides an example on how to extend an already existing widget, although I would still recommend the custom one.

I've modified the dojo using the above approach for your convenience.

Let me know if further assistance is required.

Best Regards,
Georgi Denchev
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/.

0
Mikkel
Top achievements
Rank 1
answered on 26 Jan 2021, 08:00 AM

Hi Georgi,

 

Thank you so much - that's just what I need.

I understand your recommendation, but I wish it was possible to extend your controls "natively", eg. making it possible to add custom event handlers etc.

 

Best regards

Mikkel

0
Georgi Denchev
Telerik team
answered on 26 Jan 2021, 02:15 PM

Hi Mikkel,

I am glad the solution works for you!

At this point this is the only way to extend the already existing widgets.

As always, we welcome new ideas and suggestions for improvement in our Feedback portal.

Best Regards,
Georgi Denchev
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
TextBox
Asked by
Mikkel
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Mikkel
Top achievements
Rank 1
Share this question
or