2

I have Backbone app (also using Chaplin.js on top of Backbone) and it works correctly with pushState. At some point I want to detect that app code is changed and reload page (reload app code). The problem is that when user is in '/some/path' I would like to reload backbone app and make it point to '/'. So far I tried:

when users is in /some/path -> location.reload() -> it reloads app but still in '/some/path'

when users is in /some/path -> location.href = location.origin -> it reloads app but still in '/some/path'

How I can just reload app in / path (and clearHistory) ?


This is solved - use window.location = '/'

user606521
  • 14,486
  • 30
  • 113
  • 204
  • I'm not sure if I understand correctly but you can try with this in your route `window.location.replace('#'); window.location.reload();`. – Puigcerber Apr 09 '14 at 09:43
  • 1
    Can't you do `window.location = '/';`? – aurbano Apr 09 '14 at 10:02
  • it does not work - it reloads page but still when app is loaded it is redirected to `/some/path` - I guess this is because of `pushState` - when `pushState` is used there isnt `#` in address – user606521 Apr 09 '14 at 10:03
  • @user606521 I posted it as an answer so others in your situation can find it. I originally posted it as a comment because I thought it was not the actual answer. I'm glad I could help you :) – aurbano Apr 09 '14 at 10:11

1 Answers1

1

Simply use window.location = '/';

This will redirect the user to the starting point of your application.

aurbano
  • 3,324
  • 1
  • 25
  • 39