Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2011 11:41
Show Gist options
  • Save anonymous/1228912 to your computer and use it in GitHub Desktop.
Save anonymous/1228912 to your computer and use it in GitHub Desktop.
$( "#user" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "{{routes.url_to('users', 'autocomplete')}}",
type: 'post',
dataType: "json",
data: {
format: "json",
name_startsWith: request.term
},
success: function(data) {
console.log(data);
}
});
},
minLength: 2,
select: function( event, ui ) {
$('#input_user').val(ui.item.value);
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment