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 );
}