1

I'm using jQuery Mobile. How can I create a button which changes the sort order of a list?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

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.