2

So i have a input page where the user can add or remove select menus, depending on how many items they need to choose. When the user proceeds past the page, but for some reason needs to return to it, they would usually use the back button in the browser. However, when that happens, None of the extra select menus (which I create using the Jquery .clone method) are present, only the original elements. Is there any way I can cache these cloned elements, so that they are present if the user needs to go back and change something on the previous page?

Here is the JS I am using to clone the elements

        function addSelect(tagName, divId){
            var cloner = $("select[tag=" + tagName + " ]:first").clone();
               //$(cloner).attr("id", "diffId");
               //$(cloner).attr("name", "diffName");
            $("#" + divId).append('</p>');                                      
             $("#" + divId).append(cloner);
        }

At first, the I thought the problem was that the cloned elements had the same id as the originals, so I tested that theory, as you can see from the commented out lines, but it made no difference.

Shrivar R
  • 123
  • 1
  • 12
  • 2
    you could save the selection in cookie or localStorage, and redraw them from there... – reyaner Jul 18 '14 at 13:11
  • I think this answer might be helpful, about bfcache: http://stackoverflow.com/questions/1195440/ajax-back-button-and-dom-updates – Jirico Jul 18 '14 at 13:17
  • Send the function parameter values to the next page; Create custom back button to pass the values back to origin; Check for values and call the function if they exist. – StaticVoid Jul 18 '14 at 13:27
  • Do you want something like this: http://jsfiddle.net/QsV7Y/embedded/result/ ? – soktinpk Jul 18 '14 at 13:29

0 Answers0