Question

I have created a website in HTML that has a Settings page, where the user inputs information, clicks Save and the information is saved - as in, if the text fields have text in them then the information remains in that field even if the user leaves the website. I have used jQTouch and jQuery and JavaScript to save the information and it worked fine, but when I re-created the same website with Twitter-BootStrap it stopped working.

The .js files attached to the Settings.html page are; bootstrap.js; jquery.min.js and (this is my own code) save.js

In the save.js, i saved the text fields using;

localStorage.name = $("#name").val();

and loaded them using;

$("#name").val(localStorage.name);

i was wondering if because i don't have jQTouch attached to the HTML anymore that it's stopped working? if so is there a way to change it to work with BootStrap and jQuery?

Any other code you need, just ask. I wasn't sure what you'd need and my GitHub account is experiencing problems. Thanks so much in advance xxx

Était-ce utile?

La solution

You can use getItem and setItem to save and load localStorage data this is plain Javascript.

localStorage.setItem("name", $("#name").val());

$("#name").val(localStorage.getItem("name"));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top