views:

141

answers:

1

I have tried implementing Google code into my own code yet I have been unsuccessful. Im unsure how? You could say Im very mush still a novice.

I start by explaining the code:
After clicking a link on the navigation, a click event fires on the main page, that show/display hidden links in the iframe. These links link too other pages.

The problem as follows:
Now the problem comes in if the user clicks on the back button to get back too the overview, the user`s selection is gone/hiden once more.

$("#navig li a").click (function() {
   if($("#iframeID").contents().find("title").is(":contains('item')")) {
    // Jump to overview.
     window.frames[frame].location = "overview.html";
   } else {
    //  Hide all elements after every new selection.
     $("#iframeID").contents().find("#contentID a").addClass("hidden");
   }

 var attrValue = $(this).attr("rel");
 var longStr = attrValue.split(",");
   for (i=0; i < longStr.length; i++) {
     $("#iframeID").contents().find("#contentID a:[rel='"+longStr[i]+"']").removeClass("hidden");
   };
   // Start of the cookie code. ref=http://code.google.com/p/cookies/wiki/Documentation
   var foo = $("#iframeID").contents().find("#content a").not(".hidden").attr("rel");
  $.cookie("cookieName", foo, { expires: 7 });
 return false;
});

Thank you all.

A: 

The answer was quite simple, I would say. A cookie solved my problem, oh and a jQuery event called load() very interesting stuff. Much from what I have learnt has came from the documentation but it also helps if you know what you should be looking for.

Heres a link to the event and the cookie code is below.

 // Set cookie information.
var info = $("a").attr("href");
 $.cookie('info', info, { expires: 7 });

// Reference cookie data
 alert(info);

Regards S

S.Ger
I seem to think a lot of people did not understand what I meant. Was my jargon that bad, if so never mind. I saved the results of my main event using the cookie and the load event came in because I was using a iframe.For those of you, still having trouble following me. Some times the DOM is ready but on the only on the parent not on the child. So we use the onload to make sure all necessities are accounted for.
S.Ger