I'm using jQuery Mobile. How can I create a button which changes the sort order of a list?
1 Answer
Place your data in a separate structure which you sort, e.g.
var mylist = new Array ();
mylist[0] = "entry A";
mylist[1] = "entry B";
....
From this, you can then dynamically populate your listview.
In the Button's onclick event, you'll have to do the following:
- Resort your data struct (
mylist) - clear the listview used to display the data
- Repopulate the listview from your updated data structure.
For more details on how to clear and repopulate list, see e.g. this SO question.