fixes for change propagation (conflict between knockout and jquery UI autocomplete)

This commit is contained in:
azivner
2018-02-04 23:16:45 -05:00
parent c84e15c9be
commit 3d2dc8e699
2 changed files with 12 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
const attributesDialog = (function() {
const dialogEl = $("#attributes-dialog");
const saveAttributesButton = $("#save-attributes-button");
const attributesModel = new AttributesModel();
let attributeNames = [];
@@ -35,6 +36,11 @@ const attributesDialog = (function() {
}
this.save = async function() {
// we need to defocus from input (in case of enter-triggered save) because value is updated
// on blur event (because of conflict with jQuery UI Autocomplete). Without this, input would
// stay in focus, blur wouldn't be triggered and change wouldn't be updated in the viewmodel.
saveAttributesButton.focus();
if (!isValid()) {
alert("Please fix all validation errors and try saving again.");
return;
@@ -143,6 +149,8 @@ const attributesDialog = (function() {
$(this).autocomplete("search", $(this).val());
});
$(document).on('blur', '.attribute-name', function (e) { console.log("blur!"); });
$(document).on('focus', '.attribute-value', async function (e) {
if (!$(this).hasClass("ui-autocomplete-input")) {
const attributeName = $(this).parent().parent().find('.attribute-name').val();