That is why I want to do array.
That is why I want to do array.
Or do I not understand you correctly ![]()
Hello!
Do you mean every record would have a few fields? Then change TaskToSynchronize the way it adds all necessary fields to object (also pass all necessary parameters when call new TaskToSynchronize)
Ok so let say I have 2 fields "name" and "surname" and my connection is down.
(Let say the local storage is "name" and "surname")
Now I walk in the street collecting random names, but remember my connection is down. So now I get 50 names and surnames by the end of the day.
Now that 50 names and surnames is stored in the localstorage in array. So when connection is on they must sync with my DB.
So my question is how do I store the "names" and "surnames" in the local storage is "name" and "surname". All 50 in that 2 storage fields.
So we must use array for this but how do I implement this?
(See my code that I shared above)
Sorry, not sure I understand what your problem is...
You created project http://docs.appery.io/tutorials/build..., does it work for you? Please check the way it works, check what is saved in localStorage, how. Try to change TaskToSynchronize the way so it adds objects to necessary fields: prefunction TaskToSynchronize(name, id, surname, someExtraField) {
this.id = id;
this.name = name;
this.surname = surname;
this.someExtraField = someExtraField;
}/preWhen you call new TaskToSynchronize pass necessary parameters.
Have you tried to do that?
My problem is the Offline array how to store the local variable:
(Must I use a "for" loop)
// On offline
function onOffline() {
localStorage.setItem('_isOnline', 0);
$('[dsid="lblstatus"]').text('Offline');
var components = [];
components.push(Appery("txt_e_naamvan").text());
components.push(Appery("txt_e_epos").text());
components.push(Appery("txt_e_selfoon").text());
components.push(Appery("txt_e_datum").text());
components.push(Appery("txt_e_tyd").text());
components.push(Appery("txtbank").text());
components.push(Appery("txttakkode").text());
components.push(Appery("txtrekeninghour").text());
components.push(Appery("txtreknommer").text());
components.push(Appery("txtrektipe").text());
components.push(Appery("txtbedrag").text());
var str = JSON.stringify(components);
localStorage.setItem("naamvan", JSON.stringify(str));
localStorage.setItem("epos", JSON.stringify(str));
localStorage.setItem("selfoon", JSON.stringify(str));
localStorage.setItem("datum", JSON.stringify(str));
localStorage.setItem("tyd", JSON.stringify(str));
localStorage.setItem("banknaam", JSON.stringify(str));
localStorage.setItem("taknaam", JSON.stringify(str));
localStorage.setItem("rekeninghouer", JSON.stringify(str));
localStorage.setItem("rekeningnommer", JSON.stringify(str));
localStorage.setItem("rekeningtipe", JSON.stringify(str));
localStorage.setItem("_bedrag", JSON.stringify(str));
}
Hello!
This code doesn't make sense. Let's see...
1) You create array where save values from elements on screen prevar components = [];
components.push(Appery("txt_e_naamvan").text());
components.push(Appery("txt_e_epos").text());
components.push(Appery("txt_e_selfoon").text());
components.push(Appery("txt_e_datum").text());
components.push(Appery("txt_e_tyd").text());
components.push(Appery("txtbank").text());
components.push(Appery("txttakkode").text());
components.push(Appery("txtrekeninghour").text());
components.push(Appery("txtreknommer").text());
components.push(Appery("txtrektipe").text());
components.push(Appery("txtbedrag").text()); /pre2) you save to str json-string components arrayprevar str = JSON.stringify(components);/pre3) save into different localStorage variables the same value prelocalStorage.setItem("naamvan", JSON.stringify(str));
localStorage.setItem("epos", JSON.stringify(str));
localStorage.setItem("selfoon", JSON.stringify(str));
localStorage.setItem("datum", JSON.stringify(str));
localStorage.setItem("tyd", JSON.stringify(str));
localStorage.setItem("banknaam", JSON.stringify(str));
localStorage.setItem("taknaam", JSON.stringify(str));
localStorage.setItem("rekeninghouer", JSON.stringify(str));
localStorage.setItem("rekeningnommer", JSON.stringify(str));
localStorage.setItem("rekeningtipe", JSON.stringify(str));
localStorage.setItem("_bedrag", JSON.stringify(str)); /pre
There is no point to do that...
I would highly recommend to take a look at the code here http://docs.appery.io/tutorials/build.... There is ready sample, you just need to figure out how does it work.
After reading the tutorial again I see the problem.
I dont have to do array in offline because we build array var tasksToCreate = [];
Anyway thanks for helping.