1

I have a filtered jquery list like this :

<ul id="myFilteredList" data-role="listview" data-filter="true">
  <li data-theme="b"  id="Li0" data-filtertext="selected_"><a href="#">Li element 1 </a></li>
  <li data-theme="b"  id="Li1" data-filtertext="selected_"><a href="#">Li element 2 </a></li>
  <li data-theme="b"  id="Li2" data-filtertext="selected_"><a href="#">Li element 3 </a></li>
  <li data-theme="b"  id="Li3" data-filtertext="selected_"><a href="#">Li element 4 </a></li>
  <li data-theme="b"  id="Li4" data-filtertext="selected_"><a href="#">Li element 5 </a></li>
</ul>

attribute data-filtertext="selected_" can be changed programtically as this (data-filtertext="selected_ blocked_")

<li data-theme="b"  id="Li4" data-filtertext="selected_ blocked_"><a href="#">Li element 5 </a></li>

using this code:

$('#myFilteredList').children('#Li4').attr('data-filtertext', 'selected_ blocked');
$('#myFilteredList').listview('refresh');

The problem is when I try to filter blocked elements it don´t show Li element 5, what I'm missing ?

Demo here: http://jsfiddle.net/SU6xY/

Steps to reproduce:

  1. Go to Demo.
  2. Type blocked at filter bar, the results show Lielement 2
  3. Press Alter Filter button, it changes li2 element filter to none and li4 element filter to blocked.
  4. Type again blocked at filter bar, it still shows Lielement 2 , it must show Lielement 4

It only works if the list are never filtered. If you try to filter and then apply new data-filtertext, the filter doesn't work.

6
  • A jsfiddle demonstration would be very helpful Commented Dec 15, 2012 at 15:43
  • I don't know about your code, but in your question that's what you're missing: the jQuery. Can you show us what you're doing? Commented Dec 15, 2012 at 15:43
  • where's the filtering code? Commented Dec 15, 2012 at 15:46
  • Ok .. i'm going to put the Jsfiddle Commented Dec 15, 2012 at 15:46
  • The jsFiddle allready available. Commented Dec 15, 2012 at 17:34

2 Answers 2

2

Lose:

$('#myFilteredList').listview('refresh'); 

You don't need it here, it is used to restyle a listview.

Without it it is working in my jsFiddle example: http://jsfiddle.net/Gajotres/5f3By/

If your content is added dynamically then modify data-filtertext after a listview refresh.

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

3 Comments

Tks, do you know why this happens?. If add some new elements to the list ('refresh') is not neccesary ?
You need to refresh after adding a new element, but change li attribute data-filtertext after a listview refresh.
Just an issue, it only works if none filter was applyed before the data-filtertext is changed?.. any other ideas ?
0

I'm not sure if this is the solution but you could perhaps try using the jQuery .data() method to change the data attribute's value?

http://api.jquery.com/data/

1 Comment

Tks for your help, but reading the api docs, it cant't help with my problem.

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.