Ember.TextSupport Class packages/ember-handlebars/lib/controls/text_support.js:11

PRIVATE

Shared mixin used by Ember.TextField and Ember.TextArea.

Show:

Methods

Properties

Show:

apply

(obj)

Parameters:

obj

Returns:

applied object

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.

Parameters:

event Event

create

(arguments) static

Parameters:

arguments

detect

(obj) Boolean

Parameters:

obj

Returns:

Boolean

focusIn

(event)

Called when the text area is focused.

Uses sendAction to send the focus-in action.

Parameters:

event Event

focusOut

(event)

Called when the text area is blurred.

Uses sendAction to send the focus-out action.

Parameters:

event Event

insertNewline

(event)

Called 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.

Parameters:

event Event

keyPress

(event)

Called when the user presses a key. Enabled by setting the onEvent property to keyPress.

Uses sendAction to send the key-press action.

Parameters:

event Event

reopen

(arguments)

Parameters:

arguments

triggerAction

(opts) Boolean

Send an action with an actionContext to a target. The action, actionContext and target will be retrieved from properties of the object. For example:

1
2
3
4
5
6
7
8
9
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.

1
2
3
4
5
6
7
8
9
10
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:

1
2
3
4
5
6
7
8
9
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:

opts Hash
(optional, with the optional keys action, target and/or actionContext)

Returns:

Boolean
true if the action was sent successfully and did not return false
Show:

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 the 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 enter
  • keyPress: the user pressed a key

Default: enter