Reputation: 5524
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:
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.
Upvotes: 1
Views: 527
Reputation: 57309
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.
Upvotes: 2
Reputation: 1559
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?
Upvotes: 0