Skip to content

Commit

Permalink
Add Clear option - Clears all options in the dropdown list.
Browse files Browse the repository at this point in the history
  • Loading branch information
cohenyoh committed May 1, 2017
1 parent ce108ed commit 9fcb3f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ Adds a new option in the dropdown list. You can choose the position where to ins

Removes an option in the dropdown list at the given index.

### `.editableSelect('clear');`

Clears all options in the dropdown list.

### `.editableSelect('destroy');`

Destroys the typeahead field and restores the `<select>` input.
Expand Down
5 changes: 5 additions & 0 deletions dist/jquery-editable-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
this.$select.find('option').eq(index).remove();
this.filter();
};
EditableSelect.prototype.clear = function () {
this.$list.find('li').remove();
this.$select.find('option').remove();
this.filter();
};
EditableSelect.prototype.destroy = function () {
this.$list.off('mousemove mousedown mouseup');
this.$input.off('focus blur input keydown');
Expand Down
5 changes: 5 additions & 0 deletions src/jquery-editable-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
this.$select.find('option').eq(index).remove();
this.filter();
};
EditableSelect.prototype.clear = function () {
this.$list.find('li').remove();
this.$select.find('option').remove();
this.filter();
};
EditableSelect.prototype.destroy = function () {
this.$list.off('mousemove mousedown mouseup');
this.$input.off('focus blur input keydown');
Expand Down

0 comments on commit 9fcb3f0

Please sign in to comment.