jQuery UI AutoComplete中的自定义值
我正在使用jQuery UI AutoComplete ,我想知道如何传递自定义值。
我可以使用Option定义自定义值吗? 不太确定我应该如何使用它。 目前我通过传递URL中的值来解决“问题”,如下所示:
source: "http://mysite.com/wp-content/themes/theme1/include/jquery.search.php?limit=5",
你可以用一个函数替换source,就像这样
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 }); };
查看http://jqueryui.com/demos/autocomplete/#remote-jsonp
这有将数据传递到后端的源。