0

我在一个视图中,我想将操作发送到与我所在的视图不同的控制器或路由器。我该怎么做?

App.FormView = Ember.View.extend ({

    actions: {
        clicked: function() {
            context = this.get("context");
                App.OtherViewController.send("clicked", context); //this doesn't work
            // this.get("controller").send("clicked", context); // this sends to the current controller
        }
    }
});
4

1 回答 1

1

如果你FormController needs有一些ThingController,你可以FormView通过做得到它this.get('controller.controllers.thing')。从内部FormController你会使用this.get('controllers.thing').

App.FormController = Ember.ObjectController.extend({
  needs : ['thing']
});

App.FormView = Ember.View.extend ({
    actions: {
        clicked: function() {
            context = this.get("context");
            // this sends to the ThingController
            this.get("controller.controllers.thing").send("clicked", context); 
        }
    }
});
于 2013-09-23T04:44:10.050 回答