ember-router

Ember deeply nested routes do not keep parent dynamic parameter

泄露秘密 提交于 2019-12-05 01:32:34
I've got this ember application: Ember : 1.3.2 Ember Model : 0.0.11 Handlebars : 1.3.0 jQuery : 1.9.1 Using this resource map: App.Router.map(function () { this.resource('dimensions', function() { this.resource('dimension', { path: ':dimension_id'}, function () { this.resource('value', { path: 'values/:value_id' }); }); }); }); And this allows me to embed {{outlet}} in "dimensions" template that fills with "dimension" template, and embed {{outlet}} in "dimension" template that fills with "value" template as well. All works very well except for the link-to helper in the "value" template, that

How to access controller from route in Ember?

岁酱吖の 提交于 2019-12-04 22:18:04
Is there any foolproof way to access controller from a route? <a href="#" class="btn" {{action "someAction" user}}>add</a> App.ApplicationRoute = Ember.Route.extend events: someAction: (user) -> console.log 'give me name from currentUser controller' The someAction is very general and I think that ApplicationRoute is the best place for it. mavilein I think the method controllerFor should be available in this event: App.ApplicationRoute = Ember.Route.extend events: someAction: (user) -> console.log this.controllerFor("currentUser").get("name") Update in response to the questions in the comments:

Ember.js RC1 get name of route

可紊 提交于 2019-12-04 15:45:38
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 and the user interacts # with the special offers, they will be redirected back # to wherever they

How do I use dynamic segments in EmberJS' 2.2 router?

本秂侑毒 提交于 2019-12-04 09:39:32
问题 I can't figure out how to create routes with dynamic segments in the new router API for EmberJS. I've spent a week on it and tried many things but it doesn't work. I am really frustrated at myself because I've gone through the docs, API and source code many times and cannot figure out how to make this work. I am dying for assistance. I am trying to achieve the following routes: /profile/:userId -> index /profile/:userId/activity -> activity page /profile/:userId/... My router is set up like

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

旧城冷巷雨未停 提交于 2019-12-04 07:23:22
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 outside the router? I could ask the router for a transition, but I don't want to modify the URL, as I'm

Emberjs-1.0.0-rc.6 using enumerable to list events occurring on a particular date

夙愿已清 提交于 2019-12-04 06:22:08
问题 When I define a controller action to display dates occuring a particular date, it works correctly, but If I convert that controller action to a property it stops displaying the date occuring on a particular event. The jsfiddle App.EventsController = Em.ArrayController.extend({ todayEvent: function(date){ return this.get('content').filter(function(event) { return (moment(event.get('start')).unix() == moment(date).unix()); }); } }); I can fetch an instance of the controller: u = App.__container

Ember JS transition to nested routes where all routes are dynamic segments from a view

╄→гoц情女王★ 提交于 2019-12-04 01:21:19
We are writing an application using EmberJS. However we are still new with this framework and we're having a hard time resolving some of what may seem to be straight forward. The model is pretty simple, there are 3 models: Queue, Task, and Image. We are using dynamic URI segments for all routes and routes for these models are nested in the form: :queue_id/:task_id/:image_id. The routes are configured this way: App.Router.map(function() { this.resource('queue', {path: ':queue_id'}, function() { this.resource('task', {path: ':task_id'}, function() { this.resource('image', {path: ':image_id'}); }

Nested Routing Behavior for Ember.js

强颜欢笑 提交于 2019-12-03 21:49:45
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 ArtistsIndexRoute // Template: artists OR artists/index this.resource('artists.artist', { path: '

What's the proper way to access parameters from within Ember.Route. setupController?

余生长醉 提交于 2019-12-03 15:34:04
问题 Ember.Route.model has access to the params variable, but Ember.Route.setupController does not. This is troublesome for me, because my path has multiple dynamic segments, and I need to use all of them in my template. Specifically, my path looks like this: /project/:project_id/task/:task_id . Note that a task can belong to many projects, not just one. Therefore we can't tell what project we're looking at just be looking at the task itself: we have to use the project ID found in the URL. Here's

How do I disambiguate nested routes in ember.js?

眉间皱痕 提交于 2019-12-03 15:07:32
I have two resources that both have the same sub-resource: App.Router.map(function() { this.resource('post', function() { this.resource('comments', function() { this.route('new'); }); }); this.resource('product', function() { this.resource('comments', function() { this.route('new'); }); }); }); The problem is that the ember router builds the names of the route objects out of just the current and parent routes, not out of the whole hierarchy. Thus, it tries to route both /posts/:id/comments/new and /products/:id/comments/new to the App.NewCommentRoute object. What can I do to fix this? This