Change event fired twice on ComboBox using AngularJS

3 posts, 0 answers
  1. Cory
    Cory avatar
    11 posts
    Member since:
    Jun 2014

    Posted 01 Sep 2014 Link to this post

    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. Cory
    Cory avatar
    11 posts
    Member since:
    Jun 2014

    Posted 02 Sep 2014 in reply to Cory Link to this post

    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.
  3. Kiril Nikolov
    Kiril Nikolov avatar
    2543 posts

    Posted 02 Sep 2014 Link to this post

    Hi Cory,

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

    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:

    Kiril Nikolov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top