I observe a undesired behaviour when it comes to the browser back button and emberjs. If the user clicks on the back button, the page shows twice the rendered handlebar template.
In case that the history is long enough, that “works” even several times and the page gets longer and longer. Somebody seen that issue already (and even solved it)?
My application is currently quite what is shown by Trek at http://trek.github.com/ except that I moved to the new router API of pre4.
Versions
- emberjs 1.0 pre4
- handlebars 1.0 rc1
Follow-up to my own question. There are two issues in my code. One of them I tracked down and share here the solution in case somebody have similar issues.
I had a model definition like
The
allMembers: []was a reference that retained all members. Upon going back/forth, members for reloaded from the backend and stored again onallMembers.To resolve this one, just define
allMembersinfindAll:There is a second issue that is most probably also related to the way I combined the routes. I will post on it as soon as I have the solution.
Update, 2013-01-22
Ok, the second issue has been found as well and emberJS + back button now works perfectly. Again, I would like to quickly summarize what the problem was in case that somebody stumbles over it as well.
The routing definition looked as follows:
Furthermore, ‘new’ and ‘area’ used the very same view and controller. So, the issue was between the parent route ‘area’ and its subroute ‘new’. The attempt to combine all together, and do some magic within the controller to distinguish which case it is, is just not recommended…
So, solution was:
And the code would be
That’s it. Enjoy or comment. Always glad to get input from experts