I know a blob can be saved with the tm transformmanager https://zimjs.com/docs.html?item=TransformManager
but I want to save data into an TextInput , but how
I found the copy to clipboard for text
but when I refresh text is is away into the texinput
Thanks to help
Use localStorage.myText = textInput.text for instance when it changes in an "input" event. Then as you load the page use if (localStorage.text) textInput.text = localStorage.text; or something like that.
I tried but don"t know how, I found into docs this
my zapp
do you have a video about localstorage?
localStorage is plain JavaScript so not in the ZIM docs. It is really easy so try it out with some simple things. Here is a quick lesson page I use with some of my students. Web Programming - Interactive Media - Sheridan Please look at THIS PAGE ONLY and do not go into the whole lessons site and start asking about or wanting things there.
@abstract I looked to your coockie example
and tried to covert it to ZIM
but it is not saving yet the text that is typed inside the textInput
What did I do wrong?
my zapp
thanks to help
and thanks to share your lesoons websites at Sherdian
looking forward to learn everything
If I have time
localStorage can store text and numbers without using JSON. You would use JSON for arrays, object literals, boolean - although storing a 1 or 0 can be easier for boolean. So for just text in a TextInput you do not need JSON. You can use it, and that is not the issue with your code - just letting you know.
There are two sides to localStorage. Adding things to localStorage and retrieving things from localStorage.
If you are using JSON when you add it then you JSON.stringify() to turn it into a string so localStorage can store it.
localStorage.data = JSON.stringify(data);
If you have used JSON to store, and you now want to retrieve the data from localStorage then you use JSON.parse() to turn the string that was saved back into proper JavaScript data - like a real array object, etc.
data = JSON.parse(locaStorage.data);
You have tried to retrieve localStorage data in the place where you should be trying to save localStorage data.
ok, I tried to use your information and changed the parse example
but it seems not saving localStorage.data
=> when I want to load the storage a get error
so what is wrong in my code?
also this is not working to parse
so no localStorage is saved, even when I do a refresh?
sorry I don't understand
my zapp
https://zimjs.com/zapp/E_5Y24Wa
I have not looked but maybe you need to test if there is localStorage.data before you try and parse it - the first time there may not be any data.
so:
if (localStorage.data) data = JSON.parse(locaStorage.data);
sometimes we test for locaStorage at all in case old browsers... but probably do not need to for your app.