Input keyup event operations inside dataitem.set method will lead to input loses focus.
The code is below:
keyupHandler: function(e){ var _id = e.target.name; var _configItemValue = e.target.value; var dataItem = that.options.dataSource.get( _id ); // above focus is ok dataItem.set( "configItemValue", _configItemValue ); // input focus lost // I had hoped to focus way in this focus, but has no effect $(e.target).focus();}
HTML Code:
<input class="k-textbox" data-bind="events: { keyup: keyupHandler}" />how to avoid this problem?
5 Answers, 1 is accepted
0
Hello,
I am not sure what could cause the focus to be lost. Could you provide the full code that your using?
Regards,
Daniel
Telerik
I am not sure what could cause the focus to be lost. Could you provide the full code that your using?
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
ye
Top achievements
Rank 1
answered on 19 Jun 2015, 07:53 AM
Attach is my full code.
0
ye
Top achievements
Rank 1
answered on 19 Jun 2015, 07:54 AM
0
Accepted
Hello again,
The focus will be lost because the treelist will be redrawn. The set method will trigger the change event and the treelist is redrawn on change. You could restore the focus by using an approach similar to the one in the snippet below:
but a simpler solution would be to assign the value without the set method:
Regards,
Daniel
Telerik
The focus will be lost because the treelist will be redrawn. The set method will trigger the change event and the treelist is redrawn on change. You could restore the focus by using an approach similar to the one in the snippet below:
dataItem.set( "configItemValue", _configItemValue );$("#treelist").find("tr[data-uid='" + dataItem.uid + "'] .searchInput").focus();var dataItem = that.options.dataSource.get( _id );dataItem.configItemValue = _configItemValue;dataItem.dirty;Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
ye
Top achievements
Rank 1
answered on 24 Jun 2015, 02:10 AM
I tried both method, is all ok. Thanks!