开发者

jQuery UI Autocomplete showing two sources as soon as each is loaded

So I have a jQuery 开发者_如何学编程UI Autocomplete. What I am trying to do is make it show the combination of two results coming from a PHP file. The file can print either a normal PHP array (print_r) or a JSON string.

I have the Autocomplete working with one source, but the problem is my two sources are: first one super fast, the other takes time to come from database..

Anyway to make them appear separately, as soon as they load? I.e. when the first source finishes, it gets shown while the other one is loading from database.. and then once it is ready it is added to the end of the list already shown?

Thanks!


Maybe you can overwrite 'search' method to show some kind of 'loading' gif while data is retrieving from database (using and Ajax call too could work)

http://jqueryui.com/demos/autocomplete/#method-option

EDIT: I don't know if this is going to work, but probably you will catch the global idea of what I want

var availableTags = [
   "ActionScript",
   "AppleScript",
   "Asp",
   "BASIC"
];
$( "#tags" ).autocomplete({
   source: availableTags
});

$.ajax({
   url: 'other_data.php'
   type: json,
   success: function(data){
      $('#tags').source = $('#tags').source.concat(data);
   }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜