Tip
Submitted by Mehrdad Rafiee:
You can extend a text field using Ember.TextField.extend().
Imagine you have a search input component like so:
1 |
{{search-input value=searchTerm}} |
This component will have the “active” class whenever the input field has a value.
1 2 3 4 5 6 7 |
export default Ember.TextField.extend({ type: 'search', isExpanded: computed('value', function() { return Boolean(this.get('value')); }), classNameBindings: ['isExpanded:active'] }); |
Check this live demo for more information.
Credits & Links
Thank you Mehrdad for this tip.
Free Programming Books and lifetime access to IconApp.io
I am giving away some programming books and lifetime access to iconapp.io library of awesome icons. Check it out at https://gleam.io/XqHjW/rock-and-roll-with-emberjs
Share A Tip
Email me at emad@emberdaily.tips if you have a good ember tip.
If you are enjoying my daily tips please spread the word with this one-click tweet.
If you do NOT like the tips then please reply to this email and let me know how I can improve them.