ember-router

Ember.js RC1 get name of route

走远了吗. 提交于 2019-12-06 09:57:08
问题 I have an ember application where I do some conditional redirecting, but would like to be able to pass the request on through to it's original location after the user has jumped through some hoops. I've got something like this (coffeescript) Ember.Route.reopen: -> redirect: -> if @controllerFor('specialOffers').get('should_offer') #This next line is what I need help with @controllerFor('specialOffers').set('pass_through', HOW_DO_I_GET_STRING_NAME_OF_CURRENT_ROUTE) # After this property is set

Emberjs Modals on a route

蓝咒 提交于 2019-12-06 09:20:29
So I am trying to figure out how best to put modals on a route, such that you can navigate to them via the url. application.hbs {{outlet}} {{outlet modal}} There is a discussion here and emberjs cookbook provides another example but nothing covers how you can have modals on a specific route. The closest thing I have seen is this Stack Overflow question but it suffers from two problems: When the modal route is visited, the view in the main outlet gets destroyed. So in your UI, things underneath the modal get wiped out. history.back() is that you essentially revisit that route causing that view

How to pass Model route name item to linkTo in template in ember.js

天涯浪子 提交于 2019-12-06 07:06:56
How do I pass a route name to a {{linkTo}} dynamically? For example, given this code: App.Router.map(function() { this.resource('anon', {path: '/main'}, function() { this.route('home', {path:'/home'}); this.route('about', { path: '/about' }); this.route('contact', { path: '/contact' }); }); }); App.NavController = Ember.ArrayController.extend({ selectedNav:'', setNav:function(value){ var nav = App.Nav.find(value); var items = nav.get('navItems'); this.set('content', items); } }); these templates: <script type="text/x-handlebars" data-template-name="nav"> <ul class="nav"> {{#each in controller}

The route i came from, or previous route

跟風遠走 提交于 2019-12-06 04:25:04
When i visit one route and then go to another, is where a way to know which route i came from? I tried document.referrer - this doesn't work. Googling hadn't brought any answers either.. I set up this fiddle for example and testing.. There is no direct solution using the API. Meaning, this information is not part of the public API. However, you can cache this information yourself. App.set('lastRoutes', []); App.BaseRoute = Ember.Route.extend({ setupController: function() { this._super.apply(this, arguments); App.get('lastRoutes').pushObject(this.get('routeName')); } }); Use "setupController",

Ember.js pre4, how to do the previous pre2 connectOutlet stuff

大城市里の小女人 提交于 2019-12-06 02:48:04
问题 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 fill an outlet named 'modal' added to the 'application' template, with my data. Now, in pre4 I have no reference to the controllers created by the router. How would you fill an outlet from

<OUTDATED> about {{linkTo}} in Ember.js Guide

China☆狼群 提交于 2019-12-05 23:19:52
问题 I'm reading guide of Ember.js templates. In the handlebar part of the first example of above link, they used {{#linkTo posts.post post}} but I thought {{#linkTo posts.post}} would work. Why do I need second argument 'post'? I read the explanation: If the route has a dynamic segment, a model that represents the segment. By default, Ember.js will replace the segment with the value of the object's id property. but I can't associate this explanation with question above. 回答1: The #linkTo helper

I18n in EmberJS (routing and in general)

无人久伴 提交于 2019-12-05 13:22:50
Does EmberJS support translated routes for internationalized apps? Or does it at least make it easy to extend it to support i18n routes? Anybody with experience with this? E.g. can the route string be somehow set dynamically from locale files? Also it would be cool when using Ember with Rails routing would not have to be specified twice... is that so? I'm new to Ember (currently evaluating js frameworks) but I assume in general with Rails one would simply specify very basic routes from within Rails and the rest in Ember? So there wouldn't be much duplication? Wonder if locale files from Rails

Ember-Router: How to add a route in run-time in Ember 1.0-rc2?

一曲冷凌霜 提交于 2019-12-05 10:45:15
In the new Ember.Router that shipts with Ember 1.0-rc2, is it possible add route in run-time? There is not a supported method of doing this currently. The App.Router.map call is handled by lines 235-247 of this code: https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/system/router.js Ember.Router.reopenClass({ map: function(callback) { var router = this.router = new Router(); var dsl = Ember.RouterDSL.map(function() { this.resource('application', { path: "/" }, function() { callback.call(this); }) }); router.map(dsl.generate()); return router; } The map is overwritten

Ember.js - Call parent model hook to load data for child

喜欢而已 提交于 2019-12-05 09:55:25
I have a master/detail view in Ember. If i am calling the detail page directly, the model hook of the detail page needs the model(data) from the parent(master). The detail model hook is called - whats the proper way to get/call the model so the modelFor function in the detail hook works. Router: App.Router.map(function(){ this.resource('index', { path: '/' } ); this.resource('devices', { path: '/devices'}, function() { this.resource('device', { path: ':imei'}); }); }); Master Route: App.DevicesIndexRoute = Ember.Route.extend({ model: function() { var self = this; return requestController.get({

Nested Routing Behavior for Ember.js

[亡魂溺海] 提交于 2019-12-05 04:42:28
问题 Can someone explain the behavior of the router and nested routes in Ember.js? What are the resulting URL, RouteName, Controller, Route, and Template? App.Router.map(function(){ this.resource('profile'); // URL: /profile // RouteName: profile // Controller: ProfileController // Route: ProfileRoute // Template: profile this.resource('artists', function(){ // URL: /artists // RouteName: artists OR artists.index // Controller: ArtistsController OR ArtistsIndexController // Route: ArtistsRoute OR