Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically build list view JQueryMobile

I need to dynamically add a list view. I am able to build the list view dynamically but i am appending

  • to hard coded tag in the below html snippet.
    The HTML code snippet.
    <ul id="mymenu" data-role="listview" >
    </ul>
    
    Jquery Code Snippet.
    $("#accpmenu").append('<li><a href='+ "#" + ' id="a"  "> <img src="letterheader.png" >'+ this.textContent + '  </a> </li>'); 
    

    I even want to dynamically build the and then append

  • Please help me in achieving this.

    Thanks Shyam

  • like image 362
    shyamshyre Avatar asked Jan 06 '12 05:01

    shyamshyre


    2 Answers

    After appending you must refresh the list:

      $("#mymenu").listview("refresh");
    
    like image 160
    mram888 Avatar answered Nov 01 '22 04:11

    mram888


    Here is an example which creates a list dynamically.

    http://jsfiddle.net/SuSpv/

    Let me know if that helps.

    like image 26
    user700284 Avatar answered Nov 01 '22 05:11

    user700284