Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo numeric textbox change event without lost focus

Is it possible to configure the kendo numeric textbox that my bound view model will receive an update when i click on the spin or change the numbers with keys? At the moment, only if the numeric text box lose the focus my view model will receive the update event.

The kendo databinding option data-value-update ... has sadly no effect on numeric text boxes

Thanks for any help

like image 870
ZwenigHirni Avatar asked Jan 06 '14 10:01

ZwenigHirni


2 Answers

I know it's kinda late but here is my solution:

var numericBox = $("#yournumericinput").data("kendoNumericTextBox");
.
.
.
numericBox.element.on("keyup", function (e) {
    var newValue = e.target.value;        
    numericBox.value(newValue);
    numericBox.trigger("change");
});

That way the change event gets triggered immediately after the user has entered a new value, without having to wait for the blur event. Data validation checks are removed for brevity, but I advise you perform those as well.

And you could also bind the spin listener to trigger the change event.

numericBox.bind("spin", function (e) {
     this.trigger("change");
});
like image 122
Martin Shishkov Avatar answered Nov 18 '22 14:11

Martin Shishkov


You can try the below code. It works for me.

ViewModel

viewModel.bind("change", function (e) {
        console.log("property Changed on spin ");
    });

Razor code

 <input id="tbSlideDuration" data-role="numerictextbox"
                             data-format="#"
                             data-min="1"
                             data-max="100"
                             data-bind="value:slideDuration, events: {spin:change}" />

this will call the change event under the hood :)

like image 35
maxspan Avatar answered Nov 18 '22 14:11

maxspan