开发者

How to use jQuery UI Autocomplete with multiple values with Oracle ApEx?

I am using Oracle Application Express (ApEx v3.0.1) and I would like to use jQuery UI – Autocomplete with Multiple values example.

See: http://jqueryui.com/demos/autocomplete/#multiple

Basically, looking at the source for this example, it has the following variable dataset:

        var availableTags = [
        "ActionScript",
        "AppleScript",
        "Asp",
        "BASIC",
        "C",
        "C++",
        "Clojure",
        "COBOL",
        "ColdFusion",
        "Erlang",
        "Fortran",
        "Groovy",
        "Haskell",
        "Java",
        "JavaScript",
        "Lisp",
        "Perl",
        "PHP",
        "Python",
        "Ruby",
        "Scala",
        "Scheme"
    ];

What I would like to do and unsure how to do with Oracle ApEx is reference a database table via an on-demand process and retrieve customer names where I would like a user to select multiple values from or even just a single value.

The only issue too though is, this table has开发者_如何学运维 over 90,000 records and so not sure what the best way to do this.

Pretty much, I would like to do it like Stack Overflow does it when choosing the tags for a question.


You can pass a function as the source option:

$(stuff).autocomplete({
    source: function(request, response) {
      $.ajax({
          url: '/your/autocompleter?pat=' + encodeURIComponent(request.term),
          type: 'get',
          success: function(data) {
              response(data.split('\n'));
          },
          // Other AJAX options as needed
      }),
      // Other autocomplete options as needed
});

Then, /your/autocompleter would get what they've currently entered in the pat parameter and use that to query your database to find possible matches. To get the possible matches back to the autocompleter, you'd just have to return the possible matches as a list of strings — one match per line — with a content type of text/plain. You don't need to use the "one per line" plain text format but that's probably the easiest, you only need to ensure that the success callback can parse the /your/autocompleter return data into an array to hand to response.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜