MDL-53730 form: Autocomplete triggers change event on change only

This commit is contained in:
Frederic Massart
2016-05-06 09:27:29 +08:00
committed by Andrew Nicols
parent 456b8a602c
commit 1eaba735f5
2 changed files with 17 additions and 6 deletions
File diff suppressed because one or more lines are too long
+16 -5
View File
@@ -109,15 +109,21 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
});
}
}).fail(notification.exception);
// Because this function get's called after changing the selection, this is a good place
// to trigger a change notification.
if (typeof M.core_formchangechecker != 'undefined') {
};
/**
* Notify of a change in the selection.
*
* @param {jQuery} originalSelect The jQuery object matching the hidden select list.
* @return {Void}
*/
var notifyChange = function(originalSelect) {
if (typeof M.core_formchangechecker !== 'undefined') {
M.core_formchangechecker.set_form_changed();
}
originalSelect.change();
};
/**
* Remove the given item from the list of selected things.
*
@@ -146,6 +152,8 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
}
// Rerender the selection list.
updateSelectionList(options, state, originalSelect);
// Notifiy that the selection changed.
notifyChange(originalSelect);
};
/**
@@ -402,7 +410,8 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
});
updateSelectionList(options, state, originalSelect);
// Notifiy that the selection changed.
notifyChange(originalSelect);
// Clear the input field.
inputElement.val('');
// Close the suggestions list.
@@ -440,6 +449,8 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
});
// Rerender the selection list.
updateSelectionList(options, state, originalSelect);
// Notifiy that the selection changed.
notifyChange(originalSelect);
// Clear the input element.
inputElement.val('');
// Close the list of suggestions.