Page 3 of 9

saving labels to array

Posted: Tue Sep 24, 2013 12:02 pm
by Michael4771079

saving labels to array

Posted: Tue Sep 24, 2013 12:29 pm
by Maryna Brodina

Please use prefavorites.push(new_item);/pre instead prefavorites.append(new_item);/pre


saving labels to array

Posted: Tue Sep 24, 2013 2:44 pm
by Michael4771079

Thanks that solved the error.

I now have the array saving in local storage,
I tried to create a put service, but I am getting error

Image

this is the service settings

Image


saving labels to array

Posted: Tue Sep 24, 2013 2:47 pm
by Michael4771079

Image

mapping with the following js

codecode

Image

/code/code


saving labels to array

Posted: Tue Sep 24, 2013 2:51 pm
by Michael4771079

codereturn JSON.parse(localStorage.getItem("favorites"));/code


saving labels to array

Posted: Tue Sep 24, 2013 8:13 pm
by Kateryna Grynko

Hi Michael,

Field "favorites" in your collection stores a string, not an object. That is, you don't need code:codereturn JSON.parse(localStorage.getItem ("favorites"));/code

When you request the data from database you would need to take into account that it is a string you need to convert into the structure.


saving labels to array

Posted: Tue Sep 24, 2013 8:28 pm
by Michael4771079

Katya,
in this service its a put
i have removed above code
return JSON.parse(localStorage.getItem ("favorites"));

and I get this in the console

Image

Image


saving labels to array

Posted: Tue Sep 24, 2013 9:06 pm
by Kateryna Grynko

Hi Michael,

You don't have the object of service settings or it is not specified in service settings. The problem is that {database_url} doesn't exist. You need to define it as a parameter database_url or connect settings object, which specifies this parameter.


saving labels to array

Posted: Tue Sep 24, 2013 9:18 pm
by Michael4771079

I sorry Katya,
I dont understand


saving labels to array

Posted: Wed Sep 25, 2013 1:16 am
by Igor

Hi Michael,

Please take a look at screen shot

Image