Class TextArea
publicimport TextArea from '@ember/component/text-area'; |
The internal class used to create textarea element when the {{textarea}}
helper is used.
See Ember.Templates.helpers.textarea for usage details.
Layout and LayoutName properties
Because HTML textarea
elements do not contain inner HTML the layout
and
layoutName
properties will not be applied.
actions public
Inherited from Ember.ActionHandler packages/ember-runtime/lib/mixins/action_handler.js:22
The collection of functions, keyed by name, available on this
ActionHandler
as action targets.
These functions will be invoked when a matching {{action}}
is triggered
from within a template and the application's current route is this route.
Actions can also be invoked from other parts of your application
via ActionHandler#send
.
The actions
hash will inherit action handlers from
the actions
hash defined on extended parent classes
or mixins rather than just replace the entire hash, e.g.:
banner.js | |
1 2 3 4 5 6 7 8 9 |
import Mixin from '@ember/mixin'; export default Mixin.create({ actions: { displayBanner(msg) { // ... } } }); |
app/routes/welcome.js | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import Route from '@ember/routing/route'; import CanDisplayBanner from '../mixins/can-display-banner'; export default Route.extend(CanDisplayBanner, { actions: { playMusic() { // ... } } }); // `WelcomeRoute`, when active, will be able to respond // to both actions, since the actions hash is merged rather // then replaced when extending mixins / parent classes. this.send('displayBanner'); this.send('playMusic'); |
Within a Controller, Route or Component's action handler,
the value of the this
context is the Controller, Route or
Component object:
app/routes/song.js | |
1 2 3 4 5 6 7 8 9 10 11 |
import Route from '@ember/routing/route'; export default Route.extend({ actions: { myAction() { this.controllerFor("song"); this.transitionTo("other.route"); ... } } }); |
It is also possible to call this._super(...arguments)
from within an
action handler if it overrides a handler defined on a parent
class or mixin:
Take for example the following routes:
route.js | |
1 2 3 4 5 6 7 8 9 |
import Mixin from '@ember/mixin'; export default Ember.Mixin.create({ actions: { debugRouteInformation() { console.debug("It's a-me, console.debug!"); } } }); |
debug.js | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import Route from '@ember/routing/route'; import DebugRoute from '../mixins/debug-route'; export default Route.extend(DebugRoute, { actions: { debugRouteInformation() { // also call the debugRouteInformation of mixed in DebugRoute this._super(...arguments); // show additional annoyance window.alert(...); } } }); |
Bubbling
By default, an action will stop bubbling once a handler defined
on the actions
hash handles it. To continue bubbling the action,
you must return true
from the handler:
app/router.js | |
1 2 3 4 5 |
Router.map(function() { this.route("album", function() { this.route("song"); }); }); |
app/routes/album.js | |
1 2 3 4 5 6 7 8 |
import Route from '@ember/routing/route'; export default Route.extend({ actions: { startPlaying: function() { } } }); |
song.js | |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import Route from '@ember/routing/route'; export default Route.extend({ actions: { startPlaying() { // ... if (actionShouldAlsoBeTriggeredOnParentRoute) { return true; } } } }); |
ariaRole public
Inherited from Component packages/ember-glimmer/lib/component.js:681
The WAI-ARIA role of the control represented by this view. For example, a button may have a role of type 'button', or a pane may have a role of type 'alertdialog'. This property is used by assistive software to help visually challenged users navigate rich web applications.
The full list of valid WAI-ARIA roles is available at: http://www.w3.org/TR/wai-aria/roles#roles_categorization
attributeBindings public
Inherited from Ember.ViewMixin packages/ember-views/lib/mixins/view_support.js:18
A list of properties of the view to apply as attributes. If the property is a string value, the value of that string will be applied as the value for an attribute of the property's name.
The following example creates a tag like <div priority="high" />
.
component.js | |
1 2 3 4 5 6 |
import Component from '@ember/component'; export default Component.extend({ attributeBindings: ['priority'], priority: 'high' }); |
If the value of the property is a Boolean, the attribute is treated as
an HTML Boolean attribute. It will be present if the property is true
and omitted if the property is false
.
The following example creates markup like <div visible />
.
component.js | |
1 2 3 4 5 6 |
import Component from '@ember/component'; export default Component.extend({ attributeBindings: ['visible'], visible: true }); |
If you would prefer to use a custom value instead of the property name, you can create the same markup as the last example with a binding like this:
component.js | |
1 2 3 4 5 6 |
import Component from '@ember/component'; export default Component.extend({ attributeBindings: ['isVisible:visible'], isVisible: true }); |
This list of attributes is inherited from the component's superclasses, as well.
classNameBindings public
Inherited from Ember.ClassNamesSupport packages/ember-views/lib/mixins/class_names_support.js:37
A list of properties of the view to apply as class names. If the property is a string value, the value of that string will be applied as a class name.
1 2 3 4 5 |
// Applies the 'high' class to the view element Ember.Component.extend({ classNameBindings: ['priority'], priority: 'high' }); |
If the value of the property is a Boolean, the name of that property is added as a dasherized class name.
1 2 3 4 5 |
// Applies the 'is-urgent' class to the view element Ember.Component.extend({ classNameBindings: ['isUrgent'], isUrgent: true }); |
If you would prefer to use a custom value instead of the dasherized property name, you can pass a binding like this:
1 2 3 4 5 |
// Applies the 'urgent' class to the view element Ember.Component.extend({ classNameBindings: ['isUrgent:urgent'], isUrgent: true }); |
This list of properties is inherited from the component's superclasses as well.
classNames public
Inherited from Ember.ClassNamesSupport packages/ember-views/lib/mixins/class_names_support.js:25
Standard CSS class names to apply to the view's outer element. This property automatically inherits any class names defined by the view's superclasses as well.
element public
Inherited from Ember.ViewMixin packages/ember-views/lib/mixins/view_support.js:147
Returns the current DOM element for the view.
elementId public
Inherited from Component packages/ember-glimmer/lib/component.js:887
The HTML id
of the component's element in the DOM. You can provide this
value yourself but it must be unique (just as in HTML):
If not manually set a default value will be provided by the framework.
Once rendered an element's elementId
is considered immutable and you
should never change it. If you need to compute a dynamic value for the
elementId
, you should do this when the component or element is being
instantiated:
1 2 3 4 5 6 7 8 |
export default Component.extend({ init() { this._super(...arguments); var index = this.get('index'); this.set('elementId', `component-id${index}`); } }); |
isVisible public
Inherited from Component packages/ember-glimmer/lib/component.js:916
If false
, the view will appear hidden in DOM.
layout public
Inherited from Component packages/ember-glimmer/lib/component.js:858
Layout can be used to wrap content in a component.
positionalParams public
Inherited from Component packages/ember-glimmer/lib/component.js:696
Available since v1.13.0
Enables components to take a list of parameters as arguments.
For example, a component that takes two parameters with the names
name
and age
:
component.js | |
1 2 3 4 5 6 7 8 9 |
import Component from '@ember/component'; let MyComponent = Component.extend(); MyComponent.reopenClass({ positionalParams: ['name', 'age'] }); export default MyComponent; |
It can then be invoked like this:
The parameters can be referred to just like named parameters:
Using a string instead of an array allows for an arbitrary number of parameters:
component.js | |
1 2 3 4 5 6 7 8 9 |
import Component from '@ember/component'; let MyComponent = Component.extend(); MyComponent.reopenClass({ positionalParams: 'names' }); export default MyComponent; |
It can then be invoked like this:
The parameters can then be referred to by enumerating over the list:
tagName public
Inherited from Ember.ViewMixin packages/ember-views/lib/mixins/view_support.js:373
Tag name for the view's outer element. The tag name is only used when an
element is first created. If you change the tagName
for an element, you
must destroy and recreate the view element.
By default, the render buffer will use a <div>
tag for views.