I implemented the ember.js hashbang via ember-cli. So in my app/initializer folder I have an application.js that contains the solution from this previous question: Hashbang URLs using Ember.js
When I run the code it works great but when I go to another route I get:
Uncaught ReferenceError: set is not defined
But when I refresh the page it loads just fine until I try to go to another route.
SO
example.com/#!/
will load
example.com/#!/nextRoute
I get a Transition #1: TRANSITION COMPLETE. but nothing Renders on the page
It may not be a surprise to you to hear that the problem is that set
is undefined.
In the original implementation of HashBangLocation
that you linked to, there is a line at the top
var get = Ember.get, set = Ember.set;
In your re-implementation inside an initializer, I do not see this line. JSHint would probably find this error for you. If you look at the transpiled code, there is no definition of set
in sight.
To fix this, add the var get = Ember.get, set = Ember.set
line back into your code, or use self.set('lastSetURL', null);
instead.
So if there's no set
, how did get
manage to work? It turns out there is a bug in Ember. At one point in the source, get
is declared in global scope.