Skip to content

Instantly share code, notes, and snippets.

@meltzerj
Created April 8, 2011 05:15
Show Gist options
  • Select an option

  • Save meltzerj/909336 to your computer and use it in GitHub Desktop.

Select an option

Save meltzerj/909336 to your computer and use it in GitHub Desktop.
$(".topic_field").autocomplete({
minLength: 1,
source: '/topics.json',
focus: function(event, ui) {
$('.topic_field').val(ui.item.topic.name);
return false;
},
select: function(event, ui) {
var url = $('.edit_video').attr('action');
var val = ui.item.topic.name;
$.ajax({type:"PUT", url:(url + ".js"), data:{video:{topic_names:val}}});
return false;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment