私はasp.NETでアプリケーションを作成しています。MVC 3モデル(ビューエンジンRazor)を使用します。 jQueryオートコンプリートで適切な名前を検索して名前にEnterキーを押した後に、アプリケーションが適切なRadioButtonをチェックする方法を知りません。Enterキーを押した後、jQueryオートコンプリートを使用して検索名を検索します。
<script type="text/javascript">
$(function() {
$("#tags").autocomplete({
source: "/Home/TakeGry",
minLength: 1,
select: function (event, ui) {
// I suspect that something needs to add here
}
});
});
</script>
<table>
<tr>
<th>
<div class="demo">
<div class="ui-widget">
<label for="tags">Surowce: </label>
<input id="tags" />
<input id="hiddenElementID" type="hidden" />
</div>
</div>
</th>
<th>
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Nazwa)
</td>
<td>
// One of these RadioButton's should be checked, when I hit enter
@Html.RadioButtonFor(modelItem => item.GraID, new { id = item.GraID })
</td>
</tr>
}
jQueryオートコンプリート機能は正常に機能しますが、オートコンプリートリストから何かを選択すると、適切なRadioButtonを自動的に選択する必要があります。私はページをリロードせずに非同期的に行う方法を知らない。 – tzm
OK、このイベントハンドラの助けを借りてそれを行うことができるはずです: [link](http://docs.jquery.com/Plugins/Autocomplete/result#handler) –