Homan Mohammadi
Posts: 0
Joined: Mon Feb 17, 2014 10:30 pm

Contacts query and saving queried data

Hi,

I am having difficulty saving information loaded from a contacts_load service. I am able to get the names and phone numbers of my contacts loaded into a list. However, when I try to save the information from these labels, only the default values seem to get stored, and not the information loaded from the contacts_load service. The order of operations are:

  1. Run contacts_load when the page loads

  2. Upon "success" of contacts_load, run some JS to store the needed labels (screenshot below)

    I have some alert() commands set up to check the values of the labels, and they seem to be the default "name" and "number" values, as opposed to the actual values loaded. I have tried testing with xcode, and it appears that the contacts_load service is running properly (screenshot below).

    Is this because the "success" JS is running before the contacts_load service has finished loading? Shouldn't the "success" JS be running AFTER the contact information has been loaded?

    Thanks so much for your help!

    Page:
    Image

    JS code:
    Image

    Contacts service working properly:
    Image

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Contacts query and saving queried data

Hello!

Yes, event success executed earlier than results of service render to the page. You can retrieve these values either with event success: alert (data.name); or add JS to mapping response’s param: alert (value).

Homan Mohammadi
Posts: 0
Joined: Mon Feb 17, 2014 10:30 pm

Contacts query and saving queried data

Hi Nikita,

Thanks for your help. I'm actually not sure if that is the issue. I've tried getting the JS to run after I click on a button on the page. So I wait for all the data to load (which I can see happen visually), and then I click to have the JS run (same JS as above). However, it still only returns "name" and "number" instead of the actual loaded values (which I can see as being loaded on the page).

Do you know why this might be hapenning?

Thanks!

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

Contacts query and saving queried data

Hi ,

According to your screenshot there is no data sync issue. You have a problem with "getting certain data from listitem".

Here is the code which should help you to understand why your code doesn't work.
Please add this code under your code and check browser console logs.

pre
code
//Get all labels with name 'labelsLabelsOnPage' which should exist on the page after rendering.
var labelsLabelsOnPage = jQuery("[name='mobilelabel_20']");
console.log("Labels with 'mobilelabel_20' name: " + labelsLabelsOnPage.length);

//Now let's see text for each label
for(var i = 0; i < labelsLabelsOnPage&#46;length; i++)
console&#46;log(i + " legend, text = " + jQuery(labelsLabelsOnPage)&#46;text());
</pre>
/code

Ok, now you should know how to fix your problem and get this one(label) related to your item.

This tutorial should be helpful: http://docs.appery.io/tutorials/build...

/pre

Return to “Issues”