Skip to content

event: change binding difference between 3.4.2 and 3.5.1 #2530

@cpdog

Description

@cpdog

With a view model like this:

function ViewModel(){
  var self = this;
  self.testId = ko.observable(1);
  
  self.setTestId = function () {
    alert(self.testId())
  }
}

and HTML like:
<select data-bind="value: testId, event: { change: setTestId }">

If you look at this fiddle for 3.4.2: https://jsfiddle.net/Lbkur7sc/6/
and this one for 3.5.1: https://jsfiddle.net/dog5ze18/6/

You'll see that when changing the select value, in 3.4.2, the value in the observable has been updated by the time the setTestId function fires via the change event. In 3.5.1, the old value is in the observable. Is this an intended breaking change? I looked through the release notes and didn't see that noted anywhere. This certainly seems like a bug since, as you can see in the test case, if you get the value of the select at that point, it does not match the observable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions