问题描述
我使用的是Scriptaculous的的于Ajax.Autocompleter与不同的过滤器进行搜索。
I'm using scriptaculous's Ajax.Autocompleter for a search with different filters.
http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter
过滤器都要求我的动态数据传递到autocompleter,我已经成功地学会从以下链接做。
The filters are requiring me to pass data into the autocompleter dynamically, which I've successfully learned to do from the following link.
http://www.simpltry.com/2007/01 / 30 / ajaxautocompleter动态参数/
现在,我有多个过滤器和一个搜索框。我如何获得autocompleter发出请求的没有的输入到输入,而是通过点击一个新的过滤器?
Now, I have multiple filters and one search box. How do I get the autocompleter to make the request without typing into the input, but by clicking a new filter?
下面是一个使用案例澄清。页面加载,有多个过滤器(只是与onclicks链路),并附加了autocompleter一个输入字段。我键入查询和autocompleter请求被执行。然后,我点击不同的过滤器,和我想用相同的查询,但不同的滤波器执行的另一请求。
Here's a use case to clarify. The page loads, there are multiple filters (just links with onclicks), and one input field with the autocompleter attached. I type a query and the autocompleter request is performed. Then, I click on a different filter, and I'd like another request to be performed with the same query, but different filter.
或者更简洁地说,我怎么让autocompleter执行请求的当我想这取决于输入来触发它的的,而不是?
Or more succinctly, how do I make the autocompleter perform the request when I want, instead of depending on typing to trigger it?
推荐答案
我还发现,activate()方法很好工作。下面是我的示例code ....
I also found that the activate() method worked great. Here is my sample code....
<script type="text/javascript">
/*<![CDATA[*/
var autocomp1 = new Ajax.Autocompleter("search", "AjaxResultsListPlaceholder", "ajaxServerSideSearchHandler.php", {
frequency: 1,
minChars: 10,
indicator: "AjaxWorkingPleaseWaitPlaceholder",
} );
/*]]>*/
</script>
<form id="theform">
<input type="text" id="search" name="search" value="" />
<input type="button" id="btn_search" name="btn_search" value="Search" onclick="autocomp1.activate();" />
<div id="AjaxWorkingPleaseWaitPlaceholder" style="display: none; border: 1px solid #ffaaaa;">
</div>
<div id="AjaxResultsListPlaceholder" style="display: none;; border: 1px solid #aaffaa;">
</div>
</form>
这篇关于如何使一个于Ajax.Autocompleter执行的请求没有打字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!