Skip to content

Instantly share code, notes, and snippets.

@mrbobbybryant
Created August 27, 2015 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbobbybryant/1e0f6315dc2be5ee8c4d to your computer and use it in GitHub Desktop.
Save mrbobbybryant/1e0f6315dc2be5ee8c4d to your computer and use it in GitHub Desktop.
var acs_action = 'myprefix_autocompletesearch';
$("#autosearch").autocomplete({
source: function(req, response){
$.getJSON(AUTOSEARCH.ajaxurl+'?callback=?&action='+acs_action, req, response);
},
select: function(event, response) {
$('#added-posts').append( '<li id="' + response.item.id + '">' + response.item.label + '<i class="fa fa-pencil"></i><i class="fa fa-times"></i></li>' );
$("#autosearch_posts").attr( "value", response.item.id );
$(this).val(''); return false;
},
minLength: 3
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment