Ember.TextSupport Class
Shared mixin used by Ember.TextField and Ember.TextArea.
Item Index
Methods
apply
-
obj
Parameters:
-
objObject
Returns:
cancel
-
event
Called when the user hits escape.
Called by the Ember.TextSupport mixin on keyUp if keycode matches 27.
Uses sendAction to send the escape-press action to the controller.
Parameters:
-
eventEvent
detect
-
obj
Parameters:
-
objObject
Returns:
focusIn
-
event
Called when the text area is focused.
Parameters:
-
eventEvent
focusOut
-
event
Called when the text area is blurred.
Parameters:
-
eventEvent
insertNewline
-
event
The action to be sent when the user inserts a new line.
Called by the Ember.TextSupport mixin on keyUp if keycode matches 13.
Uses sendAction to send the enter action to the controller.
Parameters:
-
eventEvent
keyPress
-
event
The action to be sent when the user presses a key. Enabled by setting
the onEvent property to keyPress.
Uses sendAction to send the keyPress action to the controller.
Parameters:
-
eventEvent
reopen
-
arguments
Parameters:
-
argumentsObject multiple
triggerAction
-
opts
action with an actionContext to a target. The action, actionContext
and target will be retrieved from properties of the object. For example:
`javascript
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
target: Ember.computed.alias('controller'),
action: 'save',
actionContext: Ember.computed.alias('context'),
click: function() {
this.triggerAction(); // Sends the save action, along with the current context
// to the current controller
}
});
`
The target, action, and actionContext can be provided as properties of
an optional object argument to triggerAction as well.
`javascript
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
click: function() {
this.triggerAction({
action: 'save',
target: this.get('controller'),
actionContext: this.get('context'),
}); // Sends the save action, along with the current context
// to the current controller
}
});
`
The actionContext defaults to the object you are mixing TargetActionSupport into.
But target and action must be specified either as properties or with the argument
to triggerAction, or a combination:
`javascript
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
target: Ember.computed.alias('controller'),
click: function() {
this.triggerAction({
action: 'save'
}); // Sends the save action, along with a reference to this,
// to the current controller
}
});
`
Parameters:
-
optsHash(optional, with the optional keys action, target and/or actionContext)
Returns:
Properties
action
String
The action to be sent when the user presses the return key.
This is similar to the {{action}} helper, but is fired when
the user presses the return key when editing a text field, and sends
the value of the field as the context.
Default: null
bubbles
Boolean
Whether they keyUp event that triggers an action to be sent continues
propagating to other views.
By default, when the user presses the return key on their keyboard and
the text field has an action set, the action will be sent to the view's
controller and the key event will stop propagating.
If you would like parent views to receive the keyUp event even after an
action has been dispatched, set bubbles to true.
Default: false
onEvent
String
The event that should send the action.
Options are:
enter: the user pressed enterkeyPress: the user pressed a key
Default: enter
