ember-router

What's the right way to enter and exit modal states with Ember router v2?

亡梦爱人 提交于 2019-12-03 13:04:28
问题 I can't figure out the correct way to handle modal states/views with the new Ember router. More generally, how do you handle states that you can enter and exit without affecting the "main" state (the URL)? For example, a "New Message" button that is always available regardless of the current leaf state. Clicking "New Message" should open the new message modal over the current view, without affecting the URL. Currently, I'm using an approach like this: Routes: App.Router.map(function() { this

How to programmatically transition between routes using Ember.js' new Router

时光怂恿深爱的人放手 提交于 2019-12-03 12:30:29
问题 Question: How do you do programmatically transition to a new route using the new Ember.js Router? Background / Context With the old Ember.js Router you could programmatically transition between routes/states using the router's send method: //OLD Router Syntax App = Ember.Application.create({ Router: Ember.Router.extend({ root: Ember.Route.extend({ aRoute: Ember.Route.extend({ route: '/', moveElsewhere: Ember.Route.transitionTo('bRoute') }), bRoute: Ember.Route.extend({ route: '

“Dynamic segment” in Ember.js?

假装没事ソ 提交于 2019-12-03 08:46:18
Throughout the Ember.js documentation, one finds the concept of dynamic segment mentioned at several places . What does it mean? MilkyWayJoe Updating with a proper sample: Demo | Source Edit due to questions in comments: In Ember, think of the Router mechanism as a State Machine: Each Route can be seen as a State. Sometimes tho, a state can have it's own little state machine within it. With that said: A resource is a state which you have possible child states. A PersonRoute can be defined as either as a resource our a route in the <Application>.Router.map callback; it really depends on your

Accessing an instance of a controller or a view in ember

旧街凉风 提交于 2019-12-03 06:13:50
问题 My understanding is that when I run App.CheeseController = Ember.Controller.extend({ type:"brie"}); A class CheeseController is created and that when I activate the Cheese route an instance of that class is made which is what I actually touch when talking to the controller in my handlebars template. Is it possible to directly access that instantiated object from within the javascript console (or from within my program)? More generally, where do the objects that Ember automatically makes live?

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

狂风中的少年 提交于 2019-12-03 05:01:38
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 I'm doing it currently: App.TaskRoute = Ember.Route.extend({ // This works just fine: serialize:

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

こ雲淡風輕ζ 提交于 2019-12-03 03:39:22
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 this App.Router.map(function() { return this.resource("profile", function() { this.route("index", { path

In latest Ember, how do you link to a route with just the id/name of a model, rather than providing all of its attributes in the linking page?

那年仲夏 提交于 2019-12-02 20:46:56
I ran into a problem when converting from Ember 1.0-pre2 to latest master ( 43354a98 ) and the new router, namely-- If I have a route which loads just the name and ID for a bunch of records, and tries to link each of those records to another route which should display the full model, when I arrive at the new route, the new model is never loaded, and name and ID are the only attributes that are available. Example code: App.Router.map(function() { this.route("index"); this.resource("birds"); this.resource("bird", { path: "/birds/:bird_id" }); }); App.BirdsController = Ember.ArrayController

Accessing an instance of a controller or a view in ember

旧街凉风 提交于 2019-12-02 19:38:19
My understanding is that when I run App.CheeseController = Ember.Controller.extend({ type:"brie"}); A class CheeseController is created and that when I activate the Cheese route an instance of that class is made which is what I actually touch when talking to the controller in my handlebars template. Is it possible to directly access that instantiated object from within the javascript console (or from within my program)? More generally, where do the objects that Ember automatically makes live? Mike Grassotti A class CheeseController is created and that when I activate the Cheese route an

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

a 夏天 提交于 2019-12-02 10:15:01
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__.lookup("controller:events") on the event 25th, there are 2 events and I can fetch it with u

Detect route transitions in EmberJS 1.0.0-pre.4

我只是一个虾纸丫 提交于 2019-12-02 01:12:31
I am trying to detect when a route transition occurs. I've located this code snippet inside the latest version of Ember ( v1.0.0-pre.4 ) that handles the transitions: didTransition: function(infos) { // Don't do any further action here if we redirected if (infos[infos.length-1].handler.transitioned) { return; } var appController = this.container.lookup('controller:application'), path = routePath(infos); set(appController, 'currentPath', path); this.notifyPropertyChange('url'); if (get(this, 'namespace').LOG_TRANSITIONS) { Ember.Logger.log("Transitioned into '" + path + "'"); } }, I set up my