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

IE doesn't update view model when enter key pressed

4 Answers 175 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 11 Oct 2012, 12:46 AM
If you have an input element with a binding to some property in a view model object.
In Chrome, if you are in the field and press enter, the change event fires on the view model and the new value is set.
In IE (9 for me)  the event does not fire until you blur the input element.
I am working around it by adding a keypress event and manually doing 
   self.viewModel.set(valuePath, $(this).attr('value'));
when the enter key is pressed.
But its clunky and should not be necessary.

Is there some way to force IE to update the view model binding when the enter key is pressed?

Thanks.

4 Answers, 1 is accepted

Sort by
0
Roger
Top achievements
Rank 1
answered on 17 Oct 2012, 10:53 PM
Anybody....?
0
Paul
Top achievements
Rank 1
answered on 07 Oct 2015, 09:27 AM
This is still a problem, is there any better solution to this than the above?
0
Rosen
Telerik team
answered on 12 Oct 2015, 08:50 AM

Hello Paul,

The behavior you are observing is no related to Kendo UI, but it is specific to how browsers triggers change event. You may use this test page to try it for yourself - open the page in Chrome and IE9 , type something and press Enter. 
As you may know, in order to track changes the MVVM value binding listens on the change event of the input element, thus when this event is not raised, the MVVM is not notified for the updated value. You could consider using the data-value-update="keyup", as demonstrated in this online demo, to instruct the MVVM to update the model when user types. Or use the workaround which is mentioned in this forum post.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Paul
Top achievements
Rank 1
answered on 12 Oct 2015, 08:56 AM
Hello Rosen, thank you for the reply. I did indeed use the solution with the keyup event as suggested after some judicious Googling.
Tags
MVVM
Asked by
Roger
Top achievements
Rank 1
Answers by
Roger
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or