Skip to content

Commit

Permalink
Merge pull request #1149 from foohey/master
Browse files Browse the repository at this point in the history
added "change" triggers on filtering select's
  • Loading branch information
bbenezech committed May 24, 2012
2 parents ff4aea2 + 2fb5b05 commit 8fe0e3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions app/assets/javascripts/rails_admin/ra.filtering-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
select: function(event, ui) {
var option = $('<option value="' + ui.item.id + '" selected="selected">' + ui.item.value + '</option>');
select.html(option);
select.trigger("change", ui.item.id);
self._trigger("selected", event, {
item: option
});
Expand Down Expand Up @@ -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'))

Expand Down

0 comments on commit 8fe0e3e

Please sign in to comment.