Is it possible to force refresh of the view?

Boris

I have an input element. It displays duration of an activity, so valid values are only numbers. When user types in an incorrect value, I show alert and then set the input value to the last correct input value.

Since I always want to display the value with one decimal number, I have bound the input to the function, which performs the formatting.

This is the part of the view:

<inputdata-bind="value: durationString"/>

This is the part of the viewModel:

01.duration: 0;

02.

03.//Converts string from the input to duration number and vice versa. Checks whether the string is a permitted number.

04.durationString: function(value) {

05.if(value !== undefined) {

06.varvalueAsNumber = checkCorrectItemDuration(value);

07.if(valueAsNumber !== -1) {

08.this.set('duration', valueAsNumber); //new value is correct, set it

09.}

10.else{

11.this.set('duration', this.get('duration')); //new value is incorrect, set the previous value

12.}

13.}

14.else{

15.returnkendo.toString(this.get('duration'), 'n1');

16.}

17.}

The problem is on the line 11. This line is executed when the value typed in the input is incorrect. I set the duration property to the same value as the value which it already has. I thought that this would force the input element to display the value from the duration property. But since the old and the new value of the duration property is the same, the input is not forced to refresh itself and so it still displays the incorrect value.

So, is it possible to force the input to display the correct value from the viewmodel?

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.