EmberJS actions - call one action from another when wrapped within `actions`

前端 未结 1 589
野的像风
野的像风 2021-02-02 06:01

How do you call one action from another action when wrapped within actions in an EmberJS controller?

Original code that uses the now deprecated way to defin

相关标签:
1条回答
  • 2021-02-02 06:27

    You can use the send(actionName, arguments) method.

    App.IndexController = Ember.ArrayController.extend({
        actions: {
            actionFoo: function() {
                alert('foo');
                this.send('actionBar');
            },
            actionBar: function() {
                alert('bar');
            }
        }
    });
    

    Here is a jsfiddle with this sample http://jsfiddle.net/marciojunior/pxz4y/

    0 讨论(0)
提交回复
热议问题