Garrett
Posts: 0
Joined: Sat Aug 17, 2013 12:18 pm

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&#46;length; i++)
{
listHtml += '<li><a href="#">'+data+'<&#47;a><&#47;li>';
}
listHtml += '<&#47;ul>';
var listElement = $(listHtml);
Appery('mobilecontainer1')&#46;append(listElement);
listElement&#46;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).

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

With a Generic (custom JavaScript implementation) service, return the contents of an array that is saved globally

Hi, could you clarify do you have problem with implementation of Generic service? Why don't you use Echo http://docs.appery.io/documentation/r...?

Garrett
Posts: 0
Joined: Sat Aug 17, 2013 12:18 pm

With a Generic (custom JavaScript implementation) service, return the contents of an array that is saved globally

I would like to Control the Echo in runtime like in your link.
codeservice_instance_name&#46;__requestOptions&#46;echo = {"login":"a@b&#46;c", "password":"abc"}/code

so, assuming my Generic Service is called "StoreStep" and my JSON formatted global array is called "window["stepsArray"]"... How would I format the above code?
Like this?...
codeStoreStep&#46;__requestOptions&#46;echo = window["stepsArray"];/code

Additionally, where do I place this code? In StoreStep's "Success" event?

Garrett
Posts: 0
Joined: Sat Aug 17, 2013 12:18 pm

With a Generic (custom JavaScript implementation) service, return the contents of an array that is saved globally

I figured it out!

I placed it in a JS for a button click before the service is actually invoked.

I also had to change it to this...
codeHandleItems&#46;__requestOptions&#46;echo = window["stepsArray"];/code
Where "HandleItems" is the actual name of the service and not what it's called on the page under the "data" tab.

Ricardo Roque
Posts: 0
Joined: Tue Nov 26, 2013 11:22 am

With a Generic (custom JavaScript implementation) service, return the contents of an array that is saved globally

Many thanks!

It is very important using the "actual" service name and not the "instance" name (under "Data" tab). I've lost several hours using the instance name with no success. :(

Return to “Issues”