API Docs for: 1.0 pre
Show:

Ember.TextSupport Class

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

Methods

apply

(
  • obj
)

Parameters:

  • obj Object

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 to the controller.

Parameters:

  • event Event

detect

(
  • obj
)
Boolean

Parameters:

  • obj Object

Returns:

Boolean:

focusIn

(
  • event
)

Called when the text area is focused.

Parameters:

  • event Event

focusOut

(
  • event
)

Called when the text area is blurred.

Parameters:

  • event Event

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:

  • event Event

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:

  • event Event

reopen

(
  • arguments
)

Parameters:

  • arguments Object multiple

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: `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:

  • 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

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

Default: enter