Last active
December 15, 2016 21:51
Ember Debounced Input
This file contains hidden or 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
// | |
// To be used like this: | |
// | |
// | |
// {{debounced-input | |
// placeholder="1000000" | |
// value=propertyName | |
// debounceWait=300 <-- debounce wait value | |
// fireAtStart=false <-- corresponds to Ember.run.debounce’s 4th param, if false, will run at the end of wait period | |
// class="form-control" <-- all regular text input attributes work | |
// name="price" | |
// }} | |
import Ember from 'ember'; | |
export default Ember.TextField.extend({ | |
debounceWait: 500, | |
fireAtStart: true, | |
_elementValueDidChange: function() { | |
Ember.run.debounce(this, this._setValue, this.debounceWait, this.fireAtStart); | |
}, | |
_setValue: function () { | |
this.set('value', this.$().val()); | |
} | |
}); | |
@timmyomahony Was curious too, spotted here: https://github.com/emberjs/ember.js/blob/v2.6.1/packages/ember-views/lib/mixins/text_support.js#L198 Makes me nervous to overwrite as it's most likely private...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where does the
_elementValueDidChange
method come from? I can't find it anywhere in the guides forTextField
orTextSupportMixin
orComponent