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

Change event fired twice on ComboBox using AngularJS

2 Answers 352 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Cory
Top achievements
Rank 1
Cory asked on 01 Sep 2014, 05:44 PM
I'm using Kendo UI v2014.2.716 with AngularJS v1.2.18 and have a ComboBox declared like below:

<select kendo-combo-box k-options="vm.manufacturerOptions" ng-model="vm.make.ManufacturerId"></select>

My options object sets the dataSource, dataTextField, and dataValueField, while the form gets the make object via the controller's resolve property. Everything appears to work as expected and I can see the ComboBox value change appropriately if I bind a separate element to the vm.make.ManufacturerId property. The part that is confusing me, though, is that when I tab off or click off the select element the change event is fired again and the value and text both reflect the text of the ComboBox, which obviously is not what I'd expect. I've tried reproducing this in the Dojo but have been unable to, but my code isn't very complex and I can't spot what could be causing the second change event to fire when the select element loses focus.

I was hoping someone might be able to think of what could be causing the second change event to fire.

2 Answers, 1 is accepted

Sort by
0
Cory
Top achievements
Rank 1
answered on 02 Sep 2014, 05:12 AM
As they say, "garbage in, garbage out". After looking more closely at the data filling the select list, I discovered there were some items that had a name ending with a "\r" (carriage return). While I'm not sure if that's something that can be guarded against or replaced in future versions of the ComboBox, I at least know there's some data cleanup in my future.

I put together a plunk to demonstrate what's happening if you're interested.

http://plnkr.co/edit/VCG9YuodaNLr7J6aUKJv?p=preview
0
Kiril Nikolov
Telerik team
answered on 02 Sep 2014, 01:37 PM
Hi Cory,

The same can be reproduced without AngularJS being included in the project as well:

http://dojo.telerik.com/aZuwE

Such scenario is not supported, as the value field cannot be correctly parsed. In case your data comes from the server in this format, I would suggest you to use schema.parse in order to parse the data to a supported format:

http://docs.telerik.com/kendo-ui/api/framework/datasource#configuration-schema.parse

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
ComboBox
Asked by
Cory
Top achievements
Rank 1
Answers by
Cory
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or