#

API Docs for: v2.11.1
Show: Inherited Protected Private Deprecated

# Ember.TargetActionSupport Class

Extends Ember.Mixin
Defined in: `packages/ember-runtime/lib/mixins/target_action_support.js:14`
Module: ember-runtime
Parent Module: ember

`Ember.TargetActionSupport` is a mixin that can be included in a class to add a `triggerAction` method with semantics similar to the Handlebars `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is usually the best choice. This mixin is most often useful when you are doing more complex event handling in Components.

- Index
- Methods

## Item Index

### Methods

- apply
- detect
- reopen
- triggerAction

## Methods

### `apply`

(

- `obj`

)
private

Inherited from Ember.Mixin: `packages/ember-metal/lib/mixin.js:572`

#### Parameters:

- `obj` Object

#### Returns:

applied object

### `detect`

(

- `obj`

)
Boolean private

Inherited from Ember.Mixin: `packages/ember-metal/lib/mixin.js:603`

#### Parameters:

- `obj` Object

#### Returns:

Boolean:

### `reopen`

(

- `arguments`

)
private

Inherited from Ember.Mixin: `packages/ember-metal/lib/mixin.js:535`

#### Parameters:

- `arguments` Object multiple

### `triggerAction`

(

- `opts`

)
Boolean private

Defined in `packages/ember-runtime/lib/mixins/target_action_support.js:43`

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

    App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
      target: Ember.computed.alias('controller'),
      action: 'save',
      actionContext: Ember.computed.alias('context'),
      click() {
        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.

    App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
      click() {
        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:

    App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
      target: Ember.computed.alias('controller'),
      click() {
        this.triggerAction({
          action: 'save'
        }); // Sends the save action, along with a reference to this,
            // to the current controller
      }
    });

#### Parameters:

- `opts` Object

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

#### Returns:

Boolean:

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