With a Generic (custom JavaScript implementation) service, return the contents of an array that is saved globally
I have a dynamically created array that is saved globally
code
window["myArray"] = [
{
"id":"00001",
"name":"Jim",
"gender":"male",
"shift":"1st",
"note":"this is a test note"
},
{
"id":"00002",
"name":"Susie",
"gender":"female",
"shift":"2st",
"note":"this is another test note"
}
];
/code
I want to display this data in a CollapsibleSet that I have added with the visual editor and have formatted it how I want it (I do not want to add the CollapsibleSet at runtime).
I have added a Generic (custom JavaScript implementation) service called "HandleItems" and have added the appropriate responses ("$" with sublevels = "id", "name", "gender", "shift", and "note").
I have mapped the responses visually to the CollapsibleSet including the "$" to iterate the collapsblocks (or items).
If I enable a sample echo response of:
code
[
{
"id":"00001",
"name":"Jim",
"gender":"male",
"shift":"1st",
"note":"this is a test note"
},
{
"id":"00002",
"name":"Susie",
"gender":"female",
"shift":"2st",
"note":"this is another test note"
}
]
/code
and invoke the service, it works as intended.
My question is...
How can I replace that sample echo response with the global array "window["myArray"] "?
Again, I require to use the visually added CollapsibleSet.
an implementation like this:
code
var data = ["Tinker", "Tailor", "Solder", "Spy"];
var listHtml = '<ul data-role="listview">';
for(var i=0; i<data.length; i++)
{
listHtml += '<li><a href="#">'+data+'</a></li>';
}
listHtml += '</ul>';
var listElement = $(listHtml);
Appery('mobilecontainer1').append(listElement);
listElement.listview();
/code
will not work.
Also, I am not using any backend, so saving the array to some database is not an option either. This is an "offline" app (no internet required).