Skip to content

Commit

Permalink
Add auto complete js for answer form in possible answers.
Browse files Browse the repository at this point in the history
  • Loading branch information
huerlisi committed Oct 18, 2010
1 parent f3361c5 commit bd7ca4d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions public/javascripts/application.js
Expand Up @@ -52,3 +52,34 @@ $(".destroy .action").click(function() {
checkbox.attr('checked', true);
container.fadeOut('slow');
});

$("input[data-autocomplete]").autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://localhost:3000/answers.json",
dataType: "json",
data: {
per_page: 12,
by_title: request.term
},
success: function( data ) {
response( $.map( data, function( object ) {
item = object.answer;
return {
label: item.title,
value: item.title
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});

0 comments on commit bd7ca4d

Please sign in to comment.