Skip to content

Commit

Permalink
In value binding, simplify model "rejection" handling (don't trigger …
Browse files Browse the repository at this point in the history
…a change event)
  • Loading branch information
mbest committed Apr 15, 2017
1 parent 1592bdc commit 61c039f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/binding/defaultBindings/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ko.bindingHandlers['value'] = {
if (newValue === null || newValue === undefined || newValue === "") {
element.value = "";
} else {
valueUpdateHandler(); // reset the model to match the element
ko.dependencyDetection.ignore(valueUpdateHandler); // reset the model to match the element
}
}
} else {
Expand All @@ -98,7 +98,7 @@ ko.bindingHandlers['value'] = {
if (!allowUnset && newValue !== ko.selectExtensions.readValue(element)) {
// If you try to set a model value that can't be represented in an already-populated dropdown, reject that change,
// because you're not allowed to have a model value that disagrees with a visible UI selection.
ko.dependencyDetection.ignore(ko.utils.triggerEvent, null, [element, "change"]);
ko.dependencyDetection.ignore(valueUpdateHandler);
}
} else {
ko.selectExtensions.writeValue(element, newValue);
Expand Down

0 comments on commit 61c039f

Please sign in to comment.