Class TextField
publicimport TextField from '@ember/component/text-field';
The internal class used to create text inputs when the Input
component is used with type
of text
.
See Ember.Templates.components.Input for usage details.
Layout and LayoutName properties
Because HTML input
elements are self closing layout
and layoutName
properties will not be applied.
actions public
Inherited from Ember.ActionHandler packages/@ember/-internals/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.:
import Mixin from '@ember/mixin';
export default Mixin.create({
actions: {
displayBanner(msg) {
// ...
}
}
});
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:
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:
import Mixin from '@ember/mixin';
export default Mixin.create({
actions: {
debugRouteInformation() {
console.debug("It's a-me, console.debug!");
}
}
});
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:
Router.map(function() {
this.route("album", function() {
this.route("song");
});
});
import Route from '@ember/routing/route';
export default Route.extend({
actions: {
startPlaying: function() {
}
}
});
import Route from '@ember/routing/route';
export default Route.extend({
actions: {
startPlaying() {
// ...
if (actionShouldAlsoBeTriggeredOnParentRoute) {
return true;
}
}
}
});
ariaRole public
Inherited from Component packages/@ember/-internals/glimmer/lib/component.ts:799
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: https://www.w3.org/TR/wai-aria/#roles_categorization
attributeBindings public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:65
By default this component will forward a number of arguments to attributes on the the component's element:
- accept
- autocomplete
- autosave
- dir
- formaction
- formenctype
- formmethod
- formnovalidate
- formtarget
- height
- inputmode
- lang
- list
- type
- max
- min
- multiple
- name
- pattern
- size
- step
- value
- width
When invoked with {{input type="text"}}
, you can only customize these attributes. When invoked
with <Input @type="text" />
, you can just use HTML attributes directly.
classNameBindings public
Inherited from Ember.ClassNamesSupport packages/@ember/-internals/views/lib/mixins/class_names_support.js:43
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.
// Applies the 'high' class to the view element
import Component from '@ember/component';
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.
// Applies the 'is-urgent' class to the view element
import Component from '@ember/component';
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:
// Applies the 'urgent' class to the view element
import Component from '@ember/component';
Component.extend({
classNameBindings: ['isUrgent:urgent'],
isUrgent: true
});
If you would like to specify a class that should only be added when the property is false, you can declare a binding like this:
// Applies the 'disabled' class to the view element
import Component from '@ember/component';
Component.extend({
classNameBindings: ['isEnabled::disabled'],
isEnabled: false
});
This list of properties is inherited from the component's superclasses as well.
classNames public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:54
By default, this component will add the ember-text-field
class to the component's element.
concatenatedProperties public
Inherited from CoreObject packages/@ember/-internals/runtime/lib/system/core_object.js:428
Defines the properties that will be concatenated from the superclass (instead of overridden).
By default, when you extend an Ember class a property defined in
the subclass overrides a property with the same name that is defined
in the superclass. However, there are some cases where it is preferable
to build up a property's value by combining the superclass' property
value with the subclass' value. An example of this in use within Ember
is the classNames
property of Component
from @ember/component
.
Here is some sample code showing the difference between a concatenated property and a normal one:
import EmberObject from '@ember/object';
const Bar = EmberObject.extend({
// Configure which properties to concatenate
concatenatedProperties: ['concatenatedProperty'],
someNonConcatenatedProperty: ['bar'],
concatenatedProperty: ['bar']
});
const FooBar = Bar.extend({
someNonConcatenatedProperty: ['foo'],
concatenatedProperty: ['foo']
});
let fooBar = FooBar.create();
fooBar.get('someNonConcatenatedProperty'); // ['foo']
fooBar.get('concatenatedProperty'); // ['bar', 'foo']
This behavior extends to object creation as well. Continuing the above example:
let fooBar = FooBar.create({
someNonConcatenatedProperty: ['baz'],
concatenatedProperty: ['baz']
})
fooBar.get('someNonConcatenatedProperty'); // ['baz']
fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz']
Adding a single property that is not an array will just add it in the array:
let fooBar = FooBar.create({
concatenatedProperty: 'baz'
})
view.get('concatenatedProperty'); // ['bar', 'foo', 'baz']
Using the concatenatedProperties
property, we can tell Ember to mix the
content of the properties.
In Component
the classNames
, classNameBindings
and
attributeBindings
properties are concatenated.
This feature is available for you to use throughout the Ember object model, although typical app developers are likely to use it infrequently. Since it changes expectations about behavior of properties, you should properly document its usage in each individual concatenated property (to not mislead your users to think they can override the property in a subclass).
element public
Inherited from Ember.ViewMixin packages/@ember/-internals/views/lib/mixins/view_support.js:144
Returns the current DOM element for the view.
elementId public
Inherited from Component packages/@ember/-internals/glimmer/lib/component.ts:1015
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):
{{my-component elementId="a-really-cool-id"}}
<MyComponent @elementId="a-really-cool-id" />
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:
export default Component.extend({
init() {
this._super(...arguments);
var index = this.get('index');
this.set('elementId', `component-id${index}`);
}
});
isDestroyed public
Inherited from CoreObject packages/@ember/-internals/runtime/lib/system/core_object.js:577
Destroyed object property flag.
if this property is true
the observers and bindings were already
removed by the effect of calling the destroy()
method.
isDestroying public
Inherited from CoreObject packages/@ember/-internals/runtime/lib/system/core_object.js:595
Destruction scheduled flag. The destroy()
method has been called.
The object stays intact until the end of the run loop at which point
the isDestroyed
flag is set.
layout public
Inherited from Component packages/@ember/-internals/glimmer/lib/component.ts:981
Layout can be used to wrap content in a component.
max public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:193
Available since v1.4.0
The max
attribute of input element used with type="number"
or type="range"
.
mergedProperties public
Inherited from CoreObject packages/@ember/-internals/runtime/lib/system/core_object.js:502
Defines the properties that will be merged from the superclass (instead of overridden).
By default, when you extend an Ember class a property defined in
the subclass overrides a property with the same name that is defined
in the superclass. However, there are some cases where it is preferable
to build up a property's value by merging the superclass property value
with the subclass property's value. An example of this in use within Ember
is the queryParams
property of routes.
Here is some sample code showing the difference between a merged property and a normal one:
import EmberObject from '@ember/object';
const Bar = EmberObject.extend({
// Configure which properties are to be merged
mergedProperties: ['mergedProperty'],
someNonMergedProperty: {
nonMerged: 'superclass value of nonMerged'
},
mergedProperty: {
page: { replace: false },
limit: { replace: true }
}
});
const FooBar = Bar.extend({
someNonMergedProperty: {
completelyNonMerged: 'subclass value of nonMerged'
},
mergedProperty: {
limit: { replace: false }
}
});
let fooBar = FooBar.create();
fooBar.get('someNonMergedProperty');
// => { completelyNonMerged: 'subclass value of nonMerged' }
//
// Note the entire object, including the nonMerged property of
// the superclass object, has been replaced
fooBar.get('mergedProperty');
// => {
// page: {replace: false},
// limit: {replace: false}
// }
//
// Note the page remains from the superclass, and the
// `limit` property's value of `false` has been merged from
// the subclass.
This behavior is not available during object create
calls. It is only
available at extend
time.
In Route
the queryParams
property is merged.
This feature is available for you to use throughout the Ember object model, although typical app developers are likely to use it infrequently. Since it changes expectations about behavior of properties, you should properly document its usage in each individual merged property (to not mislead your users to think they can override the property in a subclass).
min public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:182
Available since v1.4.0
The min
attribute of input element used with type="number"
or type="range"
.
pattern public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:172
The pattern
attribute of input element.
positionalParams public
Inherited from Component packages/@ember/-internals/glimmer/lib/component.ts:814
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
:
import Component from '@ember/component';
let MyComponent = Component.extend();
MyComponent.reopenClass({
positionalParams: ['name', 'age']
});
export default MyComponent;
It can then be invoked like this:
{{my-component "John" 38}}
The parameters can be referred to just like named parameters:
Name: {{name}}, Age: {{age}}.
Using a string instead of an array allows for an arbitrary number of parameters:
import Component from '@ember/component';
let MyComponent = Component.extend();
MyComponent.reopenClass({
positionalParams: 'names'
});
export default MyComponent;
It can then be invoked like this:
{{my-component "John" "Michael" "Scott"}}
The parameters can then be referred to by enumerating over the list:
{{#each names as |name|}}{{name}}{{/each}}
size public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:162
The size
of the text field in characters.
tagName public
Inherited from Ember.ViewMixin packages/@ember/-internals/views/lib/mixins/view_support.js:349
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.
If the tagName is ''
, the view will be tagless, with no outer element.
Component properties that depend on the presence of an outer element, such
as classNameBindings
and attributeBindings
, do not work with tagless
components. Tagless components cannot implement methods to handle events,
and have no associated jQuery object to return with $()
.
type public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:138
The type
attribute of the input element.
value public
Defined in packages/@ember/-internals/glimmer/lib/components/text-field.ts:127
As the user inputs text, this property is updated to reflect the value
property of the HTML
element.