如何将其从 Prototype 更改为 jQuery?
我想将以下 Prototype.js 转换为 jQuery。
window.onload = function () {
new Ajax.Autocompleter("function_name", "autocomplete_choices",
base_url+"application/ajaxsearch/", {});
$('function_search_form').onsubmit = function () {
inline_results();
return false;
}
}
function inline_results() {
new Ajax.Updater ('function_description',
base_url+'application/ajaxsearch',
{method:'post', postBody:'description=true&function_name='+$F('function_name')});
new Effect.Appear('function_description');
}
HTML 如下
<form id="function_search_form" method="post"
action="http://127.0.0.1/ci_sample/index.php/application/search">
<div>
<label for="function_name">Search by function name </label>
<input type="text" name="function_name" id="function_name" />
<input type="submit" value="search" id="search_button" />
<div id="autocomplete_choices" class="autocomplete"></div>
</div>
</form>
I want to convert the following Prototype.js to jQuery.
window.onload = function () {
new Ajax.Autocompleter("function_name", "autocomplete_choices",
base_url+"application/ajaxsearch/", {});
$('function_search_form').onsubmit = function () {
inline_results();
return false;
}
}
function inline_results() {
new Ajax.Updater ('function_description',
base_url+'application/ajaxsearch',
{method:'post', postBody:'description=true&function_name='+$F('function_name')});
new Effect.Appear('function_description');
}
HTML is the following
<form id="function_search_form" method="post"
action="http://127.0.0.1/ci_sample/index.php/application/search">
<div>
<label for="function_name">Search by function name </label>
<input type="text" name="function_name" id="function_name" />
<input type="submit" value="search" id="search_button" />
<div id="autocomplete_choices" class="autocomplete"></div>
</div>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要为第一部分获取一个 自动完成插件,但其余部分如下:
You'll need to get an Autocomplete Plugin for the first part, but the rest follows:
可能还有很多其他方法,但这就是我得到的。
您可能需要一个自动完成器插件,如下所示:
http://docs.jquery.com/Plugins/Autocomplete
其余代码看起来像这样的:
您还应该考虑使用 .serialize() 作为表单值。
Probably lots of other ways, but here's what I got.
You might need a plugin for the autocompleter like this:
http://docs.jquery.com/Plugins/Autocomplete
The rest of the code would look something like this:
You should also consider using .serialize() for the form values.