Direct communication between views is not possible. Instead, you should establish an indirect communication through your controllers. Let's consider a fictional example involving two views and their respective controllers:
You need to trigger an action from FirstView to FirstController (which in turn requires SecondController). FirstController will then pass on the action to SecondController. SecondController will perform its tasks (e.g., setting a property) and inform SecondView accordingly.
Update: Sample Scenario
Please note: This explanation assumes that you want to send data from FirstView
to SecondView
. If your event doesn't require any arguments, you can omit them.
View:
App.FirstView = Ember.View.extend({
submit : function(){
// Perform view-specific logic
var object = // Do whatever is necessary here
this.get("controller").send("actionInController", object); // No need to send an object if it's not required
}
});
Controller:
App.FirstController = Em.ObjectController.extend({
needs : ['second'],
actions : {
submitInController: function(object) {
// Implement controller-related logic
this.get("controllers.second").methodOfSecond(object);
}
},
});
App.SecondController = Em.ObjectController.extend({
someProperty : null,
methodOfSecond: function(object) {
// Set the necessary property to notify the second view
this.set("someProperty", object);
}
});