Page 1 of 1
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 1:21 am
by Joseph Yeung
Hi, Tiggzi team,
Say, on loading of a screen, I would like to use the following code
(to get some similar to mapping from REST responses)
precode
for(var i in localStorage)
{
Tiggzi ("mobilecollapsblock")= localStorage;
}
/code/pre
But it doesn't work. Any idea?
Big thanks!
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 3:52 am
by maxkatz
It's not possible to access Local Storage like that, here is the API for it: https://developer.mozilla.org/en-US/d...
Also, Tiggzi (component_name) returns a jQuery Mobile component:
http://docs.tiggzi.com/javascript-api/
code
Tiggzi ("mobilecollapsblock")= localStorage;
/code
So, both sides of the assigned are not valid.
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:18 am
by Joseph Yeung
Thx for pointing that out, Max.
I have tried this:
precode
for (var i in localStorage){
var arr = JSON.parse(localStorage);
Tiggzi('some_list').text(arr);}
/code/pre
That's with some success except that the Tiggzi just wouldn't reiterate itself.
Solving this problem, I will have it done.
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:23 am
by maxkatz
Tiggzi('id') returns a jQuery Mobile component. Please see how it works here: http://docs.tiggzi.com/javascript-api/. You probably need to use a different query.
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:25 am
by Joseph Yeung
I see, but how could I tell the component ('some_list') to reiterate itself alongside the loop? This is my question.
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:27 am
by maxkatz
A component can't iterate itself - it has to be done in a loop.
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:31 am
by Joseph Yeung
So I have to create the html components like what is done under the hood in a common REST response loop?
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:32 am
by maxkatz
If you need to create components - yes.
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 4:41 am
by Joseph Yeung
Do you mean something like this:
precode
function deleteRow(rowId) {
var rowTarget = "[dsid='myGrid'] tr:eq(" + rowId + ")"
$(rowTarget).remove();
}
/code/pre
But in the reverse way (i.e. to create row) , of course?
ref. https://getsatisfaction.com/tiggzi/to...
How do I reiterate local storage items to a collapsible block?
Posted: Mon Jan 21, 2013 5:12 am
by maxkatz
Something like that.. you should find many examples on jQuery forum and or stackoverflow.com.