wp-typeahead.js 444 B

123456789101112131415161718
  1. ( function($) {
  2. $( 'input[name="s"]' )
  3. .typeahead( {
  4. name: 'search',
  5. remote: wp_typeahead.ajaxurl + '?action=ajax_search&fn=get_ajax_search&terms=%QUERY',
  6. template: [
  7. '<div class=""><a href="{{url}}"><h5>{{value}}</h5><p>{{postContent}}</p></div></a>',
  8. ].join(''),
  9. engine: Hogan
  10. } )
  11. .keypress( function(e) {
  12. if ( 13 == e.which ) {
  13. $(this).parents( 'form' ).submit();
  14. return false;
  15. }
  16. }
  17. );
  18. } )(jQuery);