-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_fixInitState using hash mode should set initial hash #19
Comments
In fact,
if( this.mode === HISTORY ) {
if(hash) // fix it
} Then we can also fix It from Beyond that, So, your contribution may cause some issues, For example , visit the demo But I find that |
For stateman.on('notfound', function(){
this.go('app.homepage'); // or this.nav as well
}) See API for more detail
|
The issue is that I'm using |
I think I know what you mean. You have different logic between 『first load 』 and 『runtime 404』, right? But, if using what you want is:
But, you are using what you may need is :
I think it is a good idea. but instead of redirecting to stateman.start({
defaults: '/user/id'
}) So, what is your opinion ? |
Yes, it's just I meant. I thought that What do you think about this solution? _fixInitState: function(){
var pathname = _.cleanPath(this.location.pathname), hash, hashInPathName;
// dont support history popstate
if( this.mode !== HISTORY){
hashInPathName = pathname.replace(this.rRoot, "")
if( this.html5 ){
// config the html5 mode
if(hashInPathName) this.location.replace(this.root + this.prefix + hashInPathName);
} else {
// fallback to HASH mode.
if( this.defaults ) {
hashInPathName = this.defaults;
}
this.location.hash = this.prefix + hashInPathName;
}
}else if( this.mode === HISTORY /* && pathname === this.root*/){
hash = this.location.hash.replace(this.prefix, "");
if(hash) history.replaceState({}, document.title, _.cleanPath(this.root + hash))
}
} |
Using
mode === HASH
the method_fixInitState
do nothing. I think it should set the hash tothis.prefix + hashInPathName
.I would like to suggest a refactor like following on
_fixInitState
: https://github.com/leeluolee/stateman/blob/master/src/histery.js#L179-L193I made a work around using
history:change
event, but It's dirtier:The text was updated successfully, but these errors were encountered: