Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

PUT label text into an array

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.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

PUT label text into an array

Hi,

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

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

PUT label text into an array

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.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

PUT label text into an array

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

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

PUT label text into an array

Thanks Alena, that works perfectly.

Return to “Issues”