Todd Penny
Posts: 0
Joined: Sun Jan 12, 2014 4:29 pm

JavaScript Local Storage String Array - Can only access '0' element

Looking for help with the correct syntax and approach for getting the elements of a Javascript string array one at a time for an array created using a Model and declared in local storage.

This line below works and returns the correct value
var typevalue = Apperyio.storage.assetTypeListValues.get("$[0]");

This does not work
var typevalue = Apperyio.storage.assetTypeListValues.get("$[1]");

Thanks for any help.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

JavaScript Local Storage String Array - Can only access '0' element

Hi Todd -

Could you please show us how you have defined your model and storage in the builder?

Todd Penny
Posts: 0
Joined: Sun Jan 12, 2014 4:29 pm

JavaScript Local Storage String Array - Can only access '0' element

Here are a couple of images that show this. Image Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

JavaScript Local Storage String Array - Can only access '0' element

Hi Todd,

How do you set values to this storage variables? Do they have more than one item?

Todd Penny
Posts: 0
Joined: Sun Jan 12, 2014 4:29 pm

JavaScript Local Storage String Array - Can only access '0' element

They are being set using the data returned from a RESTService.

See attached picture. I can see the first value when I access it using element '0' reference.

Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

JavaScript Local Storage String Array - Can only access '0' element

Mapping like this doesn't save full response into the array.

1) Create Model and it's storage which cointains
assetTypeListValues and assetTypeListRef
http://gyazo.com/03f883b9159d2724b391...

2) Add Success event handler, which save data into storage variables:

preApperyio.storage.assetTypeList.set(data);/pre

3) please use the assetTypeList variable after it

Joe7349603
Posts: 0
Joined: Tue Jan 27, 2015 11:08 pm

JavaScript Local Storage String Array - Can only access '0' element

No intention to hijack this thread but I have somewhat similar issue.

I am using auto-complete for my app and the values I use in auto-complete are in a database where I have about 360 items. unfortunately my array only populates only 100 items from the database. Is there are limit as to how much I can push to my array. Here is the code I am using. I have also tried to specify the value of array with specified ''slots' but still no solution: var myarray= new array(360); Note that auto-completer works as intended but with only 100 Items

code
var Saccoarr = new Array();

$(data).each(function(){ Saccoarr.push($(this)[0].Sacco); });

Saccoarr = $.grep(Saccoarr,function(n){ return(n);});//remove all the null values from the array otherwise the Autocomplete wont work..

var sacco_keyword = localStorage.setItem("sacco_keyword", JSON.stringify(Saccoarr));

Appery("Sacco__textinput").autocomplete({source: Saccoarr});
/code

Joe7349603
Posts: 0
Joined: Tue Jan 27, 2015 11:08 pm

JavaScript Local Storage String Array - Can only access '0' element

Ignore this ..Found the solution which is adding Limit (1500) in the DB service.

I am still surprised that there would be a limit of 100

Todd Penny
Posts: 0
Joined: Sun Jan 12, 2014 4:29 pm

JavaScript Local Storage String Array - Can only access '0' element

Thanks. How do I reference the 'data' when it's the result of a REST call and I don't have a name reference for it?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

JavaScript Local Storage String Array - Can only access '0' element

Could you clarify what do you want to do? Full service response is able in "data" variable, so all it's children are able as other json children.

Return to “Issues”