Skip to content

Instantly share code, notes, and snippets.

@josepjaume
Created May 15, 2013 11:57
Show Gist options
  • Save josepjaume/5583459 to your computer and use it in GitHub Desktop.
Save josepjaume/5583459 to your computer and use it in GitHub Desktop.
Get hash location from URL as a fallback on Ember.js
var HashLocationFromUrl = Ember.HashLocation.extend({
getURL: function(){
var location = this.get('location');
if(location.hash){
return get(this, 'location').hash.substr(1);
}else{
return this.get('location').pathname;
}
}
});
Ember.Location.registerImplementation('hashFromUrl', HashLocationFromUrl);
App.Router.reopen({
location: 'hashFromUrl'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment