AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
It's not as elegant a solution as I had hoped for. However it's pure client side javascript, and it works with multiple pages. The user may modify those datas from the form and submit. Unfortunately this doesn't tie-in with browser history. Here is what I am doing : I have a form set component that fetch data through ajax to populate the form set. Disable back button if this is the first page If this page was not in the history, add it to the top of the stack Var thisPageIndex = pageHistory.indexOf() Var pageHistory = JSON.parse(sessionStorage.pageHistory || '') The stack is maintained with this code included in every page: // Load or create a history array I'm using the browser's sessionStorage to store a stack of page names, in order of appearance.Ī back (and potentially a forward) function, transverse the stack, invoking to call pages. This it the solution I'm going with for now. In the demos below (SO doesn't allow sessionStorage) I had to simulate both "going through the history", and "page load for every history item", so the code looks a little different, using an array and other vars and functions, but the principle should be the same:
0 Comments
Read More
Leave a Reply. |