Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Trigger a change event on the search input field like this after items are added to list.</p> <pre><code>$(".ui-input-search .ui-input-text").trigger("change"); </code></pre> <p>A sample:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.6.4.min.js"&gt;&lt;/script&gt; &lt;script&gt; $("#btn").live("click",function(){ $("#list").append("&lt;li&gt;&lt;a href='#'&gt;100&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#'&gt;200&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#'&gt;400&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#'&gt;500&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='#'&gt;1000&lt;/a&gt;&lt;/li&gt;"); $("#list").listview("refresh"); $("#page").trigger("create"); $(".ui-input-search .ui-input-text").trigger("change"); }); &lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="page" data-role="page"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Test Page&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;ul id="list" data-role="listview" data-inset="true" data-filter="true"&gt; &lt;li&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;12&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;41&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;8&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;91&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;65&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;a data-role="button" id="btn"&gt;Add more&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;&lt;!-- /page --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Demo - <a href="http://pastehtml.com/view/bnl7lpe3o.html" rel="nofollow">http://pastehtml.com/view/bnl7lpe3o.html</a></p> <p>Let me know if that helps.</p> <p><strong>Update for jQuery Mobile 1.4</strong> The filter behavior has been separated out into a <code>filterable</code> widget. You can update your listview content and rerun the filter in one swipe:</p> <pre><code>$( ".listselector" ).filterable( "refresh" ); </code></pre> <p>A nice benefit of this is that the list items are filtered immediately. You do not experience the visual glitch of seeing the items for a split second before they get filtered, as you would when manually triggering the input control. See <a href="http://api.jquerymobile.com/filterable/#method-refresh" rel="nofollow">http://api.jquerymobile.com/filterable/#method-refresh</a></p> <p>The code above would no longer work, because jQuery Mobile keeps track of the last text entered into the filter, and does not filter if the input has not changed. If you <em>did</em> want to trigger the input control, you would need the following hack to first clear the last entered input:</p> <pre><code>$(".ui-input-search input").attr('data-lastval', '').trigger("change"); </code></pre> <p>But, please use the <code>filterable</code> function going forward.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload