diff --git a/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js b/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js index 9161c953da..5e3fe06afc 100644 --- a/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +++ b/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js @@ -103,24 +103,28 @@ this.addAll.click(function(e){ widget._select($('option', widget.collection)); e.preventDefault(); + widget.selection.trigger('change'); }); /* Add to selection */ this.add.click(function(e){ widget._select($(':selected', widget.collection)); e.preventDefault(); + widget.selection.trigger('change'); }); /* Remove all from selection */ this.removeAll.click(function(e){ widget._deSelect($('option', widget.selection)); e.preventDefault(); + widget.selection.trigger('change'); }); /* Remove from selection */ this.remove.click(function(e){ widget._deSelect($(':selected', widget.selection)); e.preventDefault(); + widget.selection.trigger('change'); }); var timeout = null; diff --git a/app/assets/javascripts/rails_admin/ra.filtering-select.js b/app/assets/javascripts/rails_admin/ra.filtering-select.js index 36a461f0ab..ebe9e0a0cd 100644 --- a/app/assets/javascripts/rails_admin/ra.filtering-select.js +++ b/app/assets/javascripts/rails_admin/ra.filtering-select.js @@ -52,6 +52,7 @@ select: function(event, ui) { var option = $(''); select.html(option); + select.trigger("change", ui.item.id); self._trigger("selected", event, { item: option }); @@ -79,6 +80,14 @@ } } }) + .keyup(function() { + /* Clear select options and trigger change if selected item is deleted */ + if ($(this).val().length == 0) { + select.empty(); + select.trigger("change"); + } + }) + if(select.attr('placeholder')) input.attr('placeholder', select.attr('placeholder'))