2014-02-18 22 views
2

所以我在我的Handlebars標記中有兩個不同的出口。一個插座未命名爲{{outlet}},另一個插座名爲{{outlet modal}}(我在Ember Cookbook中實現了一個模式)。決定在路線基礎上呈現什麼樣的插座

我正在製作的應用程序的一個要求是,顯示在模式中的內容應該是可鏈接的。例如,資源「汽車」應該出現在那裏。我可以弄清楚如何建立一個到/cars/52的鏈接,並讓它在那個出口處渲染,但是我該如何製作這樣的路由規則?

你怎麼能說路線(如/cars/:car_id)在特定的出路?

回答

3

請注意,當您開始渲染到不同的插座時,您需要確保插座也被渲染(也就是說,它是當前路線的父代,例如應用程序)。

App.CarsRoute = App.Route.extend({ 
    renderTemplate: function() { 
    this.render('cars', { // the template to render 
     into: 'application',   // the route to render into 
     outlet: 'modal',    // the name of the outlet in the route's template 
     controller: 'cars'  // the controller to use for the template 
    }); 
    } 
}); 

http://emberjs.com/guides/routing/rendering-a-template/

+0

謝謝!我會很快回報 –