Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With some trick work you could do something around :</p> <p><strong>JS</strong></p> <pre><code>$( "#tags" ).autocomplete({ source: availableTags, focus:function(e){e.stopPropagation();return false;}, select:function(e){e.stopPropagation();return false;} }); </code></pre> <p><strong>CSS</strong></p> <pre><code>.ui-autocomplete .ui-state-focus{ border:0 !important; background:0 !important; } </code></pre> <p><a href="http://jsfiddle.net/techunter/zyGNQ/" rel="nofollow">http://jsfiddle.net/techunter/zyGNQ/</a></p> <p><strong>EDIT :</strong></p> <p>You need to modify the renderer then :</p> <pre><code>$( "#tags" ).autocomplete({ source: availableTags, focus:function(e, ui){ //if focusing on the extra elements return false thus doing nothing return ui.item.idx&lt;=2; }, select:function(e, ui){ //if selecting on the extra elements return false thus doing nothing return ui.item.idx&lt;=2;} }) .data( "ui-autocomplete" )._renderItem = function( ul, item ) { //small trick to get the current element index while the list is constructing, we set this as a helper for later usage inside the item. item.idx=ul[0].childElementCount; return $( "&lt;li&gt;" ) //if index is greater than 2 then we add a custom 'disable' class. this will help formating the disabled elements .toggleClass('disable',ul[0].childElementCount&gt;2) //appending the element .append( "&lt;a&gt;" + item.label + "&lt;/a&gt;" ).appendTo( ul ); }; </code></pre> <p><strong>EDIT 2, e.toElement trick</strong></p> <p>found this while looking into the event :</p> <pre><code>$("#tags").autocomplete({ source: availableTags, focus: function (e, ui) { $(e.toElement).toggleClass('ui-state-focus', ui.item.idx &lt;= 2); return ui.item.idx &lt;= 2; }, select: function (e, ui) { return ui.item.idx &lt;= 2; } }).data("ui-autocomplete")._renderItem = function (ul, item) { item.idx = ul[0].childElementCount; return $("&lt;li&gt;").append("&lt;a&gt;" + item.label + "&lt;/a&gt;").appendTo(ul); }; </code></pre> <p>No more need of the CSS.</p> <p><a href="http://jsfiddle.net/techunter/zyGNQ/" rel="nofollow">http://jsfiddle.net/techunter/zyGNQ/</a></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. This table or related slice is empty.
    1. VO
      singulars
      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