Ember.js pre4 how to do the previous material pre2 connectOutlet

In pre2, suppose I had this application code outside the router:

var controller = App.MyController.create(); controller.content = [...]; App.get('router').get('applicationController').connectOutlet({ outletName: 'modal', controller: controller, viewClass: App.MyView, context: controller }); 

That is, I am filling out the issue with the name “modal”, added to the “application” template, with my data.

Now, in pre4, I have no reference to the controllers created by the router. How can you fill the outlet outside the router?

I could ask the router about the transition, but I do not want to change the URL, because I just open the modal content with the current content.

EDIT:

This is what I came up with to fix temp by looking at the application view from the App.Router.router object .. obviously this is a dirty hack, does anyone know the best and correct way to do this in pre4?

  var controller = App.MyController.create(); controller.content = this.get('content'); var theView = App.MyView.create(); theView.set('controller', controller); App.Router.router.currentHandlerInfos[0].handler.router._activeViews.application[0].connectOutlet('modal', theView); 
+5
source share
1 answer

If you just need to add your presentation to the application, you can use my solution in this question:

What is the correct way to enter and exit modal states with Ember router v2?

But if you need to add it to the outlet, you can do this by sending an event to the router and simply rejecting it in case, without transferring it to another route.

 events: { showModal: function(){ this.render('modal', {into: 'index', outlet: 'modalOutlet', controller = this.controllerFor('modal')}); } } 

See an example script:

http://jsfiddle.net/Energiz0r/gChWa/1

+2
source

Source: https://habr.com/ru/post/950020/


All Articles