JavaScript Q: maintaining a persistent variable value between pages

Status
Not open for further replies.
I'm coming back to JS development after taking an 8 year break developing with Flash. My first site/app will need to pull in a few XML document and create everything on the pages dynamically - navigation, page content, etc. There will be different "layout pages" so it'll also be a multi-page site.

I just have a question to get me started -

When I did this kind of project before (2001), I'd put all of my controller code in a hidden frame and have it do the dynamic stuff in a frame that was visible to the user. That way I could maintain a persistent state as the user navigated.

Is this still the best approach for something like this?
 
A lot has changed in the browser JavaScript world. You'd be best off selecting an RIA framework or library to do this client-side rendering. Also, JSON has almost completely supplanted XML, unless you already have the XML. Even then people often translate it to JSON on the server-side.

Some frameworks to check out:

  • YUI (Yahoo! UI)
  • jQuery
  • Dojo
  • MooTools

As far as client-side state goes, I just put it into JavaScript variables. If you update the DOM based on asynchronous JavaScript calls, then you don't need to worry about the separate frame. (Sometimes it's still good to use a separate frame, of course.)

Edit: in fact you may have missed "Ajax" entirely, though I'd think Flash would have exposed you to it too.
 
Yep, I completely missed all of that. Having to deal with all of the browser quirks is what drove me away from it in the first place. I've kept a pulse on it at a high level and now I've bought a few books (I like dead tree reference) and working my way thought Lynda.com courses.

I plan on using jQuery since it's supported at my company. The web service that's providing the XML given it all in one big dump and JSON isn't an option that I know of. Well, it's Sharepoint so it might - just need to dig in the reference docs.
 
Status
Not open for further replies.