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

Rudimentary Routing in a Client-side Web Application: Why? What? How? #46

Closed
4 tasks done
nelsonic opened this issue Jul 21, 2018 · 1 comment
Closed
4 tasks done

Comments

@nelsonic
Copy link
Member

nelsonic commented Jul 21, 2018

Routing in Web Application is surprisingly simple.
There are only a couple of functions we need to write but we want to achieve the following goals:

Acceptance Criteria

  • URL (hash) should change to reflect navigation in the app
  • History of navigation should be preserved and
    • Browser "back button" should work.
  • Pasting or Book-marking a URL should display the desired content when the "page" is loaded

For: #44 "Elmish" Todo List Example

@nelsonic
Copy link
Member Author

setTimeout(function () { // delay for 1 second then run:
  console.log('window.location.href:', window.location.href);
  var base = window.location.href.split('#')[0];
  var active = '#/active';
  console.log('Setting the window.location.href to:', base + active);
  window.location.href = base + active;
  console.log('window.location.href:', window.location.href, 'updated!');
  console.log('window.history.length:', window.history.length);
  window.history.pushState(null, 'Active', active);
  console.log('window.history.length:', window.history.length);
}, 1000)

image

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

1 participant