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?
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
Related
I have started with ember and ember-cli. Ember-cli is somewhat different than Ember shown in most of the tutorials.
I can not understand what do I need to do to inherit my own custom "Route".
For example I made a file:
authenticated.coffee
and in it:
AuthenticatedRoute = Ember.Route.extend
Now I want to do the following:
make a new file called secret.coffee with:
SacretRoute = AuthenticatedRoute.extend
The best I got so far is import AuthenticatedRoute from '../routes/authenticated' which says that it included the file but says that it can not do .extend on undefined.
I do not quite understand it and I have googled all around so please if there is an answer somewhere please you can politely give me a link.
Thank you.
I am not familiar with coffee script but have you may have forgotten to export AuthenticaedRoute.
And also suggestion from stefanpenner who is creator of ember-cli. Don't hold reference of your extended route or controller just export it as
export default Ember.Route.extend();
I have seen an answer to this question and was directed to the Ember API Docs for using the browser's history.pushState ability
Apparently I need to add this code to my router.js file
App.Router.reopen({
location: 'auto'
});
However, doing so breaks my app! It is a very simple app so far, since I am still only learning... so its basically just a default installation with only 4 templates, 4 routes. I am using Ember App Kit which, I noticed initializes the router slightly differently than the ember guides describes.
Is there something different I need to do? or is there something I am doing wrong in general?
Ok... I found the answer, for anyone who might run into this same issue.
Ember app kit seems to define the router in a variable just called Router, so I don't need to use the conventional naming requirements.
All that needs to be added to the router.js is this:
Router.reopen({
location: 'auto'
});
:D
I am new to emberJS and I was wondering one thing about the DS.Store revision value.
From the documentation and Katz's peepcode video (which I highly recommend), you get a nice little error message in the console when the revision is too high, for instance:
App.store = DS.Store.create({
revision: 11,
adapter: DS.RESTAdapter.create({
namespace: 'api'
})
});
Could return:
Uncaught Error: Error: The Ember Data library has had breaking API changes since the last time you updated the library. Please review the list of breaking changes at https://github.com/emberjs/data/blob/master/BREAKING_CHANGES.md, then update your store's `revision` property to 4
I understand that, when this message is displayed, you have got to refer back to the breaking change page of the ember-data source code but I am really confused as of what it is I need to look into.
For the Revision 5 (the revision I am trying to upgrade too I guess), there are so many things and none seems to really apply to my app.
So, someone might be able to provide me with some guidance as far as what's the methodology around upgrading revision. Do you need to address the revision notes and then up the revision number (then repeat) OR does it mean that something has been broken and you need to use that revision number for the time being?
Sorry about the lengthy post, but I am trying to get out of my own confusion :)
Thanks!
nice to see you're giving ember a shot!
So that error message works the other way around - it's complaining that you're revision (5) is too low for the version of ember-data.js. Ember is forcing you to manually update your rev number to match the one that is current. Ember-data library is changing so fast, they want to make everyone is aware of breaking changes. If you are building something new just set the revision to whatever is current (as of today that's 11)
That peepcode video was good but is way out of date. Trying to follow along while using current version of ember is not going to work. Ember has changed a lot in the last several weeks and most of the tutorials/etc you'll find online have not caught up. Right now the best source of info is the guides: http://emberjs.com/guides
Also I'd recommend watching Tom Dale and Yehuda Katz presentation at Seattle Ember.js meetup last month: http://www.youtube.com/watch?v=_6yMxU-_ARs
As Michael said the tutorial is a bit out of date. I updated to the actual version of the libs (jquery, handlebars, ember and ember-data). Current revision for DS is 12
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixutreAdapter'
});
I'm just getting started with Ember. I'm a little confused on some things, as the guides on the main site seem to indicate different ways of working.
In the main docs (http://emberjs.com/documentation/), it indicates that a controller should just extend an ordinary Ember object like this:
Ember.Object.extend();
Which works fine for me.
Then in the guide to using Routing (http://emberjs.com/guides/outlets/) it suggests that there is a Controller object type that you can extend:
Ember.Controller.extend();
This doesn't work for me, and if I simply try to console.log Ember.Controller, its undefined.
I'm using Ember version 0.9.8.1.
Should I worry about this, or should I just carry on with extending Objects as my controllers?
0.9.8.1 is aging, and unfortunately even the guides on the site are ahead of it -- use latest (at https://github.com/emberjs/ember.js/downloads) to keep up with the most current best practices.
Update: 1.0-pre is out (emberjs.com), so that is the best to use. The docs / guides have been brought up to date.
I think #pauldechov means the specific "latest" build which you can find here: https://github.com/emberjs/ember.js/downloads
But also keep in mind that the documentation and "latest" are not always in sync.
I just played with ember routing example. It looks quite interesting. Especially if you are going to build all your application on Ember framework.
But parameters in url follows after '#'. That means you can't copy and send a link to someone if client has to login with postback (if only to set a cookie with login parameters). Is there a better option - maybe use '?' instead of '#'?
You may also have a look at Ember.Router.
There are two good start points # https://gist.github.com/2679013 and https://gist.github.com/2728699
A lot of fixes have been made the last couple of days.
EDIT
A brand new guide is now available # https://emberjs-staging-new.herokuapp.com/guides/outlets#toc_the-router
Here is a full example courtesy of https://github.com/jbrown
http://jsfiddle.net/justinbrown/C7LrM/10/