Jörn Zaefferer [ソース: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/]による jQuery Autocomplete v1.1 プラグインを特に参照しています。このプラグインにはかなりの数のバリエーションがあるようです。
オートコンプリートで提案を提供したいフィールドが複数あるため、ユーザーが入力を開始したときに追加のパラメーターをサーバーに渡そうとしています。
クエリに加えて、入力された名前属性をサーバーに送信したいのですが、extraParams 内で $(this).attr('name') を使用できないようです。
私のjQuery:
$('.ajax-auto input').autocomplete('search.php', {
extraParams: {
search_type: function(){
return $(this).attr('name');
}
}
})
これは私の HTML です。
<form method="post" action="#" id="update-form" autocomplete="off">
<ol>
<li class="ajax-auto">
<label for="form-initials">Initials</label>
<input type="text" id="form-initials" name="initials" />
</li>
<li class="ajax-auto">
<label for="form-company">Company</label>
<input type="text" id="form-company" name="company" />
</li>
</ol>
</form>
助言がありますか?