I've been trying to implement a router as specified in this guide, but I can't make it work. Can anyone give a quick code sample using the latest version of Ember to enable a router that supports routing through urls?
Asked
Active
Viewed 1,302 times
1
-
Without some code or a fiddle it's impossible to help you :) – Panagiotis Panagi Jul 08 '12 at 20:12
-
I found a solution but can't post an answer... As usual I get to bang my head against the wall for hours, then I ask a question and all the sudden the answer shows up. It seems that the debug-build you download from their website lacks some routing-functionality. Using http://cloud.github.com/downloads/emberjs/ember.js/ember-latest.js and http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js instead seems to make routing work. – Jan Sommer Jul 08 '12 at 20:22
-
You should replace `StateManager` with new `Ember.Router`. Take a look at [this question](http://stackoverflow.com/questions/11318572/right-way-to-do-navigation-with-ember/11319609#11319609), it might help you. `StateManager` is being somewhat replaced by the router mechanism – MilkyWayJoe Jul 08 '12 at 21:19
-
Yes, I did that but the debug build I downloaded on emberjs.com didn't even contain the Route-class and had no support for location: 'hash'. Guess the link on their site is either outdated or links to a somehow broken build. – Jan Sommer Jul 08 '12 at 21:29
-
Are you sure? I just downloaded from the official website the version 0.9.8.1 which contains `Ember.Router`, plus the example found in that question I mentioned is pointing to the same js file. – MilkyWayJoe Jul 08 '12 at 21:32
-
Also, take a look at [this video](http://www.youtube.com/watch?v=zrWkRHSK6A8) if you don't know how to use jsfiddle – MilkyWayJoe Jul 08 '12 at 21:35
-
I'm 100% sure... Just compared the one I'm linking to in my other comment with http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.8.1.js - the one they link to on emberjs.com. It contains Ember.Router yes - but not Ember.Route (and lacks a few other routing-related things) ... Also, the js-file he links to in the jsfiddle is the one I'm using now, and definitely not the same as the debug build on ember.js. – Jan Sommer Jul 08 '12 at 21:44
-
both files have `Ember.Router` & `Ember.Route`, and the fiddle I wrote is pointing to the latest which is the same as your previous comment – MilkyWayJoe Jul 08 '12 at 21:51
-
1No, the one you link to in your jsfiddle requires a seperate link to handlebars. It's embedded in the debug build. Go to http://emberjs.com and download the debug build. Search for "Ember.Route =". It doesn't exist. I've been dealing with this all day, and it worked like a charm when I used ember-latest.js. – Jan Sommer Jul 08 '12 at 21:54
1 Answers
3
Here is a one with ember latest, still prone to changes :)
http://jsfiddle.net/C7LrM/86/ posted by @mediastuttgart
The comments section of this Gist by wycats looks like the place where you can get updated fiddles :) https://gist.github.com/2728699#comments
This example uses:
handlebars-1.0.0.beta.6.js
Ember latest as of now:
// Version: v0.9.8.1-484-g73ac0a4
// Last commit: 73ac0a4 (2012-07-06 11:52:32 -0700)
For documentation of present code under development please go to ember source where they have documentation alongside code,
Eg: https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/router.js
https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/ in general

sabithpocker
- 15,274
- 1
- 42
- 75
-
Thanks for taking the time to answer my question! The code you're linking to certainly works, but it wasn't what caused the issue (see my discussion with MilkyWayJoe above). Anyways, no need to cause more trouble with this question - I'll accept your answer :) – Jan Sommer Jul 09 '12 at 07:10
-
@JanSommer just put this as an answer so others can easily find, sure I went through the problem you faced, I came to ask another related question I will ping you after posting that, may be you can help :) – sabithpocker Jul 09 '12 at 07:15
-
@JanSommer http://stackoverflow.com/questions/11390720/ember-routing-and-applicationcontroller-used-in-connectoutlet here is the issue I am having, may be you can help – sabithpocker Jul 09 '12 at 07:33