Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <input id="tags"/>
</body>
</html>
 
var ac = $( "#tags" ).autocomplete({
  focus: function( event, ui ) {
    if ( ui.item.disabled ) {
      event.preventDefault();
    }
  },
  
  select: function ( event, ui ) {
    if ( ui.item.disabled ) {
      event.preventDefault();
      return;
    }
    
    alert("You have selected "+ui.item.label+ " but you shouldn't have!");
  },
  
  source: [
    { label: "ActionScript", disabled: false },
    { label: "AppleScript", disabled: true },
    { label: "Asp", disabled: false },
    { label: "BASIC", disabled: true },
    { label: "Erlang", disabled: false },
    { label: "Fortran", disabled: true }
  ]
});
ac.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
  return $( "<li>" )
    .append( "<a>" + item.label + "</a>" )
    .toggleClass( "ui-state-disabled", item.disabled )
    .appendTo( ul );
};
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers