From 5eed28ce9ef1daa2b38d15094425f82e0032d62d Mon Sep 17 00:00:00 2001 From: Catouse Date: Thu, 30 May 2019 20:55:30 +0800 Subject: [PATCH] * add deselected param to change event for chosen single select control. --- src/js/chosen.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/chosen.js b/src/js/chosen.js index ea41c2d2a..534118274 100644 --- a/src/js/chosen.js +++ b/src/js/chosen.js @@ -1113,12 +1113,18 @@ MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md }; Chosen.prototype.results_reset = function() { + var oldValue = this.form_field_jq.val(); this.reset_single_select_options(); this.form_field.options[0].selected = true; this.single_set_selected_text(); this.show_search_field_default(); this.results_reset_cleanup(); - this.form_field_jq.trigger("change"); + var newValue = this.form_field_jq.val(); + var changeData = {selected: newValue}; + if (oldValue !== newValue && !newValue.length) { + changeData.deselected = oldValue; + } + this.form_field_jq.trigger("change", changeData); if(this.active_field) { return this.results_hide(); } -- GitLab