Custom values in jQuery UI AutoComplete

一笑奈何 提交于 2019-12-25 01:45:22

问题


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",

回答1:


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
          });
};



回答2:


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

That has the source for passing data to the backend.



来源:https://stackoverflow.com/questions/4819836/custom-values-in-jquery-ui-autocomplete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!