Skip to content
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

How do you make the 'hash' example work when { hashbang: true }? #231

Closed
alainux opened this issue Mar 4, 2015 · 8 comments
Closed

How do you make the 'hash' example work when { hashbang: true }? #231

alainux opened this issue Mar 4, 2015 · 8 comments
Assignees

Comments

@alainux
Copy link

alainux commented Mar 4, 2015

The question says it all. I'm trying to make the example under examples/hash/ work the same way it does, only using the { hashbang: true } option, but no avail.

I've also tried setting <base href="/hash/">, but that seems to get into an infinite redirection. After that, removing page.base('/hash') seems to do the trick, but then the location bar displays http://localhost:4000/hash/#!/hash/ and the # and #subsection links stop working properly.

How can I do this ?
Thanks

@TitanKing
Copy link

The #! is very dodge, for example if you type in the addressbar the following http://somesite.com/test#!/some-route it will work, but if you do http://somesite.com/test/#!/some-route (slash after test) it will not find the route.

So in your URLS do not have a slash after before the #!, I do not know if this will get fixed, I can probably look at it too.

@TitanKing
Copy link

Ok just to follow up, do not rely on build in { hashbang: true } rather make page.base('/#!'), this seems to solve all issues so far.

@dbismut
Copy link

dbismut commented Mar 13, 2015

Thanks @TitanKing this sure helped!

@denevell
Copy link

Not sure if this affects you, but when I disable {hashbang: true} and set page.base("/#!") and have a url like localhost/~myuser/somepath/ then when I load the url, I get http://localhost/#!/~myuser/somepath/ which obviously fails on reload. Without the leading slash in the base, I get http://localhost/~myuser/somepath/#!/~myuser/somepath/

I'm having some real problems with #!, which is a pity because it's the best feature for me in page.js. I'll try to submit some CRs.

@raine
Copy link

raine commented Jun 25, 2015

Ok just to follow up, do not rely on build in { hashbang: true } rather make page.base('/#!'), this seems to solve all issues so far.

This is really weird behavior.

@ooscarr
Copy link

ooscarr commented Jul 15, 2015

I added

page('/~myuser/somepath/', function () {
  app.route = 'home';
});

to my polymer routing.html file, it's ugly but at least it loads, using { hashbang: true }

@wenerme
Copy link

wenerme commented Sep 14, 2015

I meet the same problem, this is how I solve, awkward but works

page('/weapon/add', (ctx)=> {
      this.addWeapon();
    });
    page('/weapon/:id', (ctx)=> {
      this.showWeapon(ctx.params.id);
    });
    page('/weapon/:id/edit', (ctx)=> {
      this.editWeapon(ctx.params.id);
    });
    page('weapon/add', (ctx)=> {
      this.addWeapon();
    });
    page('weapon/:id', (ctx)=> {
      this.showWeapon(ctx.params.id);
    });
    page('weapon/:id/edit', (ctx)=> {
      this.editWeapon(ctx.params.id);
    });

After this, use http://localhost:5000/#!weapon/2/edit instead http://localhost:5000/#!/weapon/2/edit.

Will pagejs attempt to fix this ?

@matthewp
Copy link
Collaborator

Hey everyone! This sounds like the same bug as #242 which was fixed by #447.

Try out 1.8.0 and let me know if you still see this problem. I'm going to assume this is fixed and close the issue, but will reopen if you tell me otherwise. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants