Is it possible to use jQuery data-filter
to filter items brought in from external HTML via .load
?
I use jQuery's data-filter to allow users to filter lists, so that only list items which match their input are displayed.
<div data-role="content">
<ul data-role="listview" data-icon="false" data-filter="true" data-filter-placeholder="Search..." data-inset="true">
<li data-role="list-divider"> Characters </li>
<li data-filtertext="apples:oranges">Group 1</li>
<li data-filtertext="apples:bananas">Group 2</li>
...
<li data-filtertext="monkeys:boxes">Group 200</li>
</ul>
</div>
But, I want to move the list items to a separate html file, and call it using:
$("div[id^=menu]").each(function() {
var match = this.id.match(/\w+$/)[0];
$(this).load('menus/' + match + '.html');
So that I can replace all the list items with
<div data-role="content">
ul data-role="listview" data-icon="false" data-filter="true" data-filter-placeholder="Search..." data-inset="true">
<div id="menutest"></div>
</ul>
</div>
On the index page, and have the lists in menus/menutest.html
At the moment, although this'll display the lists when index is loaded, they're just static on the page and it doesn't allow them to be filtered. Can this be done?
$("div[id^=menu]").each(function() { var match = this.id.match(/\w+$/)[0]; $(this).load('menus/' + match + '.html', function() { listview('refresh'); })}};
but I'm clearly getting something wrong – user5513718 Sep 09 '17 at 05:51