user481610
user481610

Reputation: 3270

.append() not working when using phonegap

I'm currently creating a phonegap app that receives data from an API. I make use of ajax to retrieve the information and then append that information to a div. Now this workings fine in the browser but when I do this in android using phonegap nothing seems to happen and no information is appended to the div. Here is the code:

$.getJSON(
        AddressAccess+"Home/loginitems/email/"+UserEmailAddress+"/format/json",
        function(data)
        {
          $('#updateprofilename').append(data[0].Name);
        });

Upvotes: 1

Views: 1074

Answers (1)

TorchMan
TorchMan

Reputation: 274

As you say, that u're using $('.selector').append(something) - you're using jQuery Mobile for dynamic generation of markup.

When dynamically adding content (lets say a <div> to another <div> you have to refresh your content by doing something like this: $('[data-role="content"]').trigger('create'); in order to update your page-content after dynamic enhancemant.

more simple:

you have a <div> and you're dynamicly adding another <div>:

$("#YourWrapperDiv_ID").append('<div id="DynAddDiv_ID">My dynmicly added content</div>');
$("#YourWrapperDiv_ID").trigger('create');

Upvotes: 1

Related Questions