Page 1 of 1

PUT label text into an array

Posted: Sat Apr 05, 2014 6:30 pm
by Milton Davis

I have a grid with several labels in it and I want to use a REST service to the label text to PUT into an array.

This is the javascript I am trying to use in my mapping by sending the label text to my array:

var newData = [];
Appery('labelName').each( function() {
newData.push([{"Event_Details":{"Event_Locations": $(this).text(),"Time":"No Response","Lat":"No Lat","Lng":"No Lng"}}]);

console.log(newData);
});

return newData;

Is .each the correct thing to be using? It only give me the text from the first label in the grid, now the 2nd or 3rd.


PUT label text into an array

Posted: Sat Apr 05, 2014 7:52 pm
by Igor

Hi,

You can save service response to the localstorage variable.
http://docs.appery.io/documentation/r...


PUT label text into an array

Posted: Sat Apr 05, 2014 8:03 pm
by Milton Davis

That didn't answer my question. I am trying to save label text from a grid into a database using a REST service, but I can only get text from the first label in the grid.


PUT label text into an array

Posted: Mon Apr 07, 2014 3:20 am
by Alena Prykhodko

Hi Milton.

When you use 'Appery("name")' code - it always return just one element if exists.

You should change the code with jQuery('[name="...."]') analog.

Please use the following code instead of yours:
pre

var newData = [];
jQuery('[name="labelName"]').each( function() {
newData.push([{"Event_Details":{"Event_Locations": $(this).text(),"Time":"No Response","Lat":"No Lat","Lng":"No Lng"}}]);

Code: Select all

 console.log(newData);  

});

return newData;/pre


PUT label text into an array

Posted: Mon Apr 07, 2014 3:54 am
by Milton Davis

Thanks Alena, that works perfectly.