1

I would like to have one input field, where user will input search data. Once more than 2 letters are input, I will search on the server and will display found data in the separate div.

Currently I return the data as JSON. I would like to replace that with html (to format the data on the server side with GAE/django). I need to have this since the same template of data output is already used and I don't want to repeat that in javascript (with data( "autocomplete" )._renderItem). My output will also support paging.

Is there any way to replace the whole output (not just for one item)? Or, I should not use autocomplete here?

Community
  • 1
  • 1
LA_
  • 18,018
  • 53
  • 160
  • 288

1 Answers1

0

Don't use autocomplete.

If you are already formatting your output server side then there really is very little work for the javascript to do here.

Try writing your own autocomplete using the onChange event and use $.post to retrieve the resulting formatted output. It might end up as simple as:

$( '#searchbox' ).change( function() {
     var s = $(this).val();
     if(s.length > 2)
     {
         $.post("searchresults.php", { search: s }, function(data){
              $( '#resultdiv' ).html(data);
         });
     }
});

Hope that helps.

eyaka1
  • 385
  • 2
  • 9