Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After hours playing I finally found a trick to display <code>No match found</code> in jQuery autocomplete. Look at the above code and simply add a <code>div</code>, in my case <code>#ulNoMatch</code> and its style set to <code>displap:none</code>. In the callback success method check if the array returned has <code>length == 0</code>. If it is there you go, you made your day! :)</p> <pre><code>&lt;pre&gt;&lt;div class="ui-widget1" style="width: auto;"&gt; &lt;asp:TextBox ID="txtSearch" class="tb" runat="server" Width="150px"&gt; &lt;/asp:TextBox&gt; &lt;ul id="ulNoMatch" class="ui-autocomplete ui-menu ui-widget1 ui-widget1-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 16; display: none; width: 150px;"&gt; &lt;li class="ui-menu-item" role="menuitem"&gt;&lt;a class="ui-corner-all" tabindex="-1"&gt;No Matches Found&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;pre&gt; &lt;b&gt; &lt;b&gt; Enter code here &lt;script&gt; $(function () { $("input[id$='txtSearch']").autocomplete({ source: function (request, response) { $.ajax({ url: "splah.aspx/GetByName", data: "{ 'strName': '" + request.term.trim() + "' }", dataType: "json", type: "POST", //cacheLength: 1, contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { var found = $.map(data.d, function (item) { return { value: item.Name, id: item.id } }); if (found.length == 0) { $("#ulNoMatch").show(); } else { $("#ulNoMatch").hide(); } response(found); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, select: function (event, ui) { $("input[id$='txtSearch']").val(ui.item.label); $("input[id$='txtID']").val(ui.item.id); return false; }, minLength: 1 }); }); &lt;/script&gt; </code></pre>
    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. This table or related slice is empty.
    1. 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