Why this question arised??
I have used jquery Tabs in my application.
On controller I have opened First tab with employee's names.
Clicking on employee name opens another tab by just "add" facility of $j("#teamtab").tabs("add",<data like ID>)

on opening multiple tabs , if I reload the page then it closes all opened tabs
and reloaded page shows only one tab having team members name. i.e $j("#teamtab")

But what I want is if I reload page then it should maintain previously opened tab/s

I had thought of saving tab's id's in array and on reload open all of them.
but problem will be opening each and every tab will load its contents and in my case this each of tabs is containing much data
this is not proper way.

What should I do in such cases?
Can we save whole page in cache and reload it again?
or any other solution which am unaware of.

Recommended Answers

All 2 Replies

Refresh very deliberately reloads the current document in its original state. The only (and very limited) control the user has (in most browsers) is to do a "soft" or "hard" refresh;

  • Soft: accepts data from cache(s)
  • Hard: ignores cache(s) and goes back to the original source (sever). Relies on caches conforming to the spec (complex area).

Browser history (forward and back buttons) should maintain page state. Browsers have a chequered past in this regard though the current crop of major browser (together with HTML5) does seem to have gotten it right.

HTTP cookies (and more recently "local storage") are means by which client-side data may be made to persist (ie to exist beyond the life of the page). However, cookies etc. do not "save a page" as such. They merely save some data which can be read (both server-side or client-side) and acted on for any of a number of reasons - including the restoration of page state. If you want this to happen, then you have to write your documents very deliberately - it won't just happen!

Can we save whole page in cache and reload it again?

For reference, yes this can, but not using Javascript. You you want to venture into server side languages, such as PHP, then this is easily done.

Caching is a method of storing the output code to be used seperately from the 'engines' that generate it, so therefore it doesn't have to be generated each time (speeding things up). However this is for the entire page.

my case this each of tabs is containing much data

If this is the case, then you could try something like AJAX to load the content. Therefore only the tab(s) you want to look at are loaded, reducing the download time/bandwidth etc. In your situation, you could build on this if you have a lot of content.

It would be a good idea to save the tab/page in a cookie (as mentioned by @Airshow), and then use this to reload the page selecting the correct content using AJAX/jQuery .load().

Hopefully I've made that slightly clear to you without rambling on, but try to save the tab name in a cookie, and then read this to locate the content using jQuery $.load().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.