Unfortunately this is not going to work. jQuery Mobile
will fail to dynamically add filter to an existing listview.
But there's a workaround. Before you populate your listview count number of elements you are trying to populate, if number is 5 or more remove current listview and append new one at the same place. This is another strange thing, if you create a listview from scratch (with filter in mind), filter is going to be successfully generated.
I made an example for you: http://jsfiddle.net/Gajotres/SS7vJ/
$(document).on('pagebeforeshow', '#index', function(){
$('<ul>').attr({'id':'test-listview','data-role':'listview', 'data-filter':'true','data-filter-placeholder':'Search...'}).appendTo('#index [data-role="content"]');
$('<li>').append('<a href="#">Audi</a>').appendTo('#test-listview');
$('<li>').append('<a href="#">Mercedes</a>').appendTo('#test-listview');
$('<li>').append('<a href="#">Opel</a>').appendTo('#test-listview');
$('#test-listview').listview().listview('refresh');
});
Also don't forget to call .listview( twice, first without refresh parameter, and second time with a refresh parameter. Without it you will receive this error:
cannot call methods on listview prior to initialization
You can find more about this problem in this ARTICLE, to be transparent it is my personal blog. Or find it HERE. Look for the chapter called: Markup enhancement problems.