0

I store some jQuery objects in an map {"id1": jQueryObj1, "id2": jQueryObj2, etc}(the id is the identifier of the object parent), and once i have my map populated i work fine with the elements from map.

The problem is if i go on another page and come back the changes applied now don't have any effect. I check the object from map to see if they have the correct id and classes and they have but somehow they are not the elements from page anymore.

My solution was to populate again the map but i would like to avoid that and i thought maybe i have to compare the object something like that : $obj === $obj2; or could i use other method ?

I know there is .is method but that is since version 1.6 and i use 1.2.6.

Mihai
  • 631
  • 1
  • 14
  • 30

1 Answers1

0

JavaScript is an interpreted language, that means that as soon as you navigate to a different page, the objects no longer exist, and they are created again once you navigate back to the page. Unless you use a persistent way to store data across pages, all the changes you make to the objects will only exist as long as the page runtime does.

If you are using HTML5, have a look at Local Storage. It allows you to store information in-between pages without the need of a server; or just use cookies.

Andrei Nemes
  • 3,062
  • 1
  • 16
  • 22