Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How do I reiterate local storage items to a collapsible block?

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!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How do I reiterate local storage items to a collapsible block?

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.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How do I reiterate local storage items to a collapsible block?

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.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How do I reiterate local storage items to a collapsible block?

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.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How do I reiterate local storage items to a collapsible block?

I see, but how could I tell the component ('some_list') to reiterate itself alongside the loop? This is my question.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How do I reiterate local storage items to a collapsible block?

A component can't iterate itself - it has to be done in a loop.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How do I reiterate local storage items to a collapsible block?

So I have to create the html components like what is done under the hood in a common REST response loop?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How do I reiterate local storage items to a collapsible block?

If you need to create components - yes.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How do I reiterate local storage items to a collapsible block?

Do you mean something like this:

precode

function deleteRow(rowId) {
var rowTarget = "[dsid='myGrid'] tr:eq(" + rowId + ")&quot
$(rowTarget).remove();
}
/code/pre

But in the reverse way (i.e. to create row) , of course?
ref. https://getsatisfaction.com/tiggzi/to...

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How do I reiterate local storage items to a collapsible block?

Something like that.. you should find many examples on jQuery forum and or stackoverflow.com.

Return to “Issues”