私はメインビューを持っており、その中には部分的な見解があります。私の部分的な見解では、私は検索のいくつかの結果を示す表を持っています。私が望むのは、行をクリックすると、その行のデータを警告する必要があるということです。しかし、これは起こっていません。javascript/jqueryは部分ビューでは機能しません。
インターネット上でほぼすべてを試しましたが、何も見つかりませんでした。
パーシャルビュー:
@model List
<string>
<table class="table table-striped" id="tblGrid">
<thead id="tblHead">
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@for (int item = 0; item < Model.Count; item = item + 2)
{
<tr>
<td style="width: 300px">
@Model[item].ToString()
</td>
@{ int temp = item;
item = item + 1;
}
<td style="width: 100px">
@Model[item].ToString()
</td>
@{
item = temp;
}
</tr>
}
</tbody>
</table>
データがうまく取り込まれますが、JavaScriptは呼び出されません。
メイン:
<head>
<script type="text/javascript">
$(document).ready(function() {
$("#tblGrid tr").live(function() {
$(this).addClass('selected').siblings().removeClass('selected');
var value = $(this).find('td:first').html();
alert(value);
});
});
</script>
</head>
<body>
<input id="searchAttr" name="searchAttr" />
<button href="#myModal" id="openBtn" data-toggle="modal" class="btn btn-default">Search</button>
<div id="searchresults">
</div>
</body>
提供すべてのヘルプは理解されるであろう。
を追加しますか? '.live()'がまだサポートされている古いバージョンのjQueryを使用していますか? – nnnnnn
'