Two Methods for dynamically generating listView and refreshing it using JqueryMobile

Source: Internet
Author: User

Two Methods for dynamically generating listView and refreshing it using JqueryMobile

This article mainly introduces two methods for dynamically generating and refreshing listView using JqueryMobile. If you need it, you can refer to it for help.

Two Methods for dynamically generating listView and refreshing it using JqueryMobile

 

The Code is as follows:

Function queryEntfernungen (tx, results)

Alert ("This Hello works ");

Var len = results. rows. length;

// This For works fine

 

For (var I = 0; I <len; I ++ ){

$ ("Div [data-role = content] ul "). append ('<li> <a href = "' + results. rows. item (I ). name + '">' + results. rows. item (I ). name + '</a> </li> ');

}

$ ("Div [data-role = content] ul"). listview ('refresh'); // This also works

 

 

However, the following method can also be successful!

The Code is as follows:

Function query (tx, results ){

 

Var len = results. rows. length, I, j;

 

For (I = 0; I <len; I ++ ){

$ ("Div [data-role = content] ul "). append ('<li> <a href = "' + results. rows. item (I ). name + '">' + results. rows. item (I ). name + '</a> </li> ');

}

// No listview ("refresh ")!!

 

For (j = 0; j <len; j ++ ){

$ ("# Selectmenu "). append ('<option value = "' + results. rows. item (j ). id + '">' + results. rows. item (j ). name + '</option> ');

}

$ ("# Selectmenu"). selectmenu ('refresh', true );

 

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.