Steven
Steven

Reputation: 19455

Custom values in jQuery UI AutoComplete

I'm using jQuery UI AutoComplete and I'm I wonder how I can pass along custom values.

Can I use the Option to define custom values? Not quite sure how I should use it. Currently I'm solving the "problem" by passing along the values in the URL like this:

source: "http://mysite.com/wp-content/themes/theme1/include/jquery.search.php?limit=5",

Upvotes: 0

Views: 1281

Answers (2)

Mauricio
Mauricio

Reputation: 5853

you can replace source with a function, like this

source : function (request, response) {
    $.get('/yoururl/', { 'q' : request.term , 'some' : 1, 'other' : 2, 'value':3 },
          function(recv) { 
              var data = eval(recv);
             //do whatever with data to build the results 
              response(data.entities); // and pass it to response
          });
};

Upvotes: 4

Rui Jiang
Rui Jiang

Reputation: 1672

Check out http://jqueryui.com/demos/autocomplete/#remote-jsonp

That has the source for passing data to the backend.

Upvotes: 0

Related Questions