Skip to content

Instantly share code, notes, and snippets.

@tlovett1
Created October 7, 2013 19:34
Show Gist options
  • Save tlovett1/6873624 to your computer and use it in GitHub Desktop.
Save tlovett1/6873624 to your computer and use it in GitHub Desktop.
( function( $ ) {
$( '#pehub_post_quote_link' ).autocomplete( {
minLength: 3,
source: function( request, response ) {
var posts = [];
$.ajax( {
url: ajaxurl,
async: false,
type: 'POST',
data: {
search_terms: request.term,
action: 'quote_search',
nonce: pehub_data.post_quote_nonce,
},
success: function( data ) {
response( data['posts'] );
},
dataType: 'json',
} );
},
select: function( e, ui ) {
$( '.selected-quote' ).html( '<strong>This post is quoted from:</strong> ' + ui.item.label );
console.log(ui.item);
$( 'input[name=pehub_post_quote_post_id]' ).val( ui.item.value );
$( 'input[name=pehub_post_quote_site_id]' ).val( ui.item.site_id );
$( 'input[name=post_title]' ).val( ui.item.label );
tinymce.activeEditor.setContent( ui.item.content );
$( this ).val( '' );
return false;
}
} );
} )( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment