4

I am trying to create a dynamic listview in jquery mobile, after querying the facebook api, to retrieve a user's news feed. Here's part of my mark up:

markup += '<li><a href=""><img src="https://graph.facebook.com/' + id + '/picture">'+'<h4>' + name + '</h4><p>' + short_post +'....</p></a></li>';

I then have,

 $(newsfeedposts).append(markup);

$(newsfeedposts).trigger("create");

however after that when i call the

$(newsfeedposts).listview("refresh");

I get a type error: TypeError: $(...).listview is not a function

my html div tag is this

  <div data-role="content"> <div class ="post">
    <ul data-role="listview"  class="ui-listview" id="newsfeedposts" data-divider-theme="b" data-theme="a" data-overlay-theme="a" data-autodividers="true" data-inset="true">
</ul>
  </div>

please let me know if you identify what Im doing wrong.This has been taking so longg...

1 Answer 1

2

You're not using jQuery-selector the right way. To target an element with an id, use $('#element_id') and for an element with a class $('.element_class'). So, your selection should be as below.

$('#newsfeedposts').append(markup);

and then

$('#newsfeedposts').listview('refresh');
Sign up to request clarification or add additional context in comments.

4 Comments

I had already tried that but it still brings up the same error! is it not recognising the .listview() function? should i include any jquery files? I am currently using the latest version of jquerymobile <link rel="stylesheet" href="code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css"> <script src="code.jquery.com/jquery-1.9.1.min.js"></script> <script src="code.jquery.com/mobile/1.3.1/…>
js libraries are in head? jQuery before jQuery Mobile?
it works! now :) I had a jQuery script in the html file! one i didnt need. It was this <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> thats y it didnt work!
thanks and the way u said to have the append and refresh works :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.