有没有办法启动Scriptaculous的自动完成功能,以便在加载页面时使用输入字段中的默认字词进行搜索?
这样的东西?
<input type="text" id="autocomplete" class="autocomplete_input" name="autocomplete_parameter" value="friends"/>
<span id="indicator1" style="display: none">
loading
</span>
<div id="autocomplete_choices" class="autocomplete">
</div>
<script type="text/javascript">
function AutoComp() {
var myAutoCompleter = new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "url", {indicator: 'indicator1',});
}
document.onLoad = AutoComp.activate();
</script>
答案 0 :(得分:0)
我的错!
var myAutoCompleter = new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "api/usersearch/", {indicator: 'indicator1'});
document.observe("dom:loaded", function() {
myAutoCompleter.activate();
});
</script>
这就是诀窍