0

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",
2
  • I don't understand what you're doing. Do you have a live demo? Commented Jan 27, 2011 at 17:44
  • No - but on this example ?limit=5 is teh key - value. Instead of passing it in the URL, I would like to pass it as an option. Commented Jan 27, 2011 at 18:29

2 Answers 2

4

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
          });
};
Sign up to request clarification or add additional context in comments.

2 Comments

I've seen this solution in a couple of examples, but thought it would be a step back using $.get since the source is kind of repalcing this.
it's a step forward in customization :) you can pass the get parameters in the url then.
0

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

That has the source for passing data to the backend.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.