Created
November 23, 2016 13:53
-
-
Save sly7-7/3c68b4af55416ecc601a340d9e946695 to your computer and use it in GitHub Desktop.
ember-power-select-typeahead with allowClear
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import EmberPowerSelectTypeaheadTrigger from 'ember-power-select-typeahead/components/power-select-typeahead/trigger'; | |
export default EmberPowerSelectTypeaheadTrigger.extend({ | |
canClear: Ember.computed('select.searchText', 'select.disabled', 'allowClear', function() { | |
return !Ember.isEmpty(this.get('select.searchText')) && !this.get('select.disabled') && this.get('allowClear'); | |
}), | |
actions: { | |
clear(e) { | |
e.stopPropagation(); | |
let input = document.querySelector(`#ember-power-select-typeahead-input-${this.get('select').uniqueId}`); | |
input.value = ''; | |
this.get('select').actions.search(''); | |
this.get('select').actions.close(this.get('select'), e); | |
if (e.type === 'touchstart') { | |
return false; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment