1
CSHTML代碼:ASP.Net MVC - 獲取選定<tr>行從表中通的jQuery
foreach (Frame frame in Model.ListFrames)
{
<tr class="clickME" title="fred">
<input type="hidden" name="NameId" value="@frame.Id" style="border:0"/>
<input type="hidden" name="TypeId" value="@frame.Type" />
<input type="hidden" name="thirdone" value="@frame.Id" />
<td>
<a href="#" class="up"><img src="../../Content/img/up.jpg" style="border:0px" alt="Move up" /></a>
<a href="#" class="down"><img src="../../Content/img/down.jpg" style="border:0px" alt="Move down"/></a>
</td>
@if(frame.Type == string.Empty)
{ <td>
<textarea rows="1" cols="15" id="Name" name="Name" onclick="display('@frame.Id', this); LoadImage(this);"
onchange="LoadImage(this);" onkeyup="LoadImage(this);" style="height:20px">@frame.Name</textarea>
</td>
<td>
@(Html.DropDownList("MyFont", new SelectList((IEnumerable)ViewData["Font"], "Text", "Value", @frame.Font),
new { onclick="LoadImage(this);", onchange = "LoadImage(this);" }))
</td>
<td>
@(Html.DropDownList("MyColor", new SelectList((IEnumerable)ViewData["Color"], "Text", "Value", @frame.Color),
new { onclick="LoadImage(this);" , onchange = "LoadImage(this);" }))
</td>
<td>
@(Html.Telerik().NumericTextBox()
.Name("onTime" + frame.Id)
.MinValue(0)
.Value(frame.OnTime)
.InputHtmlAttributes(new { style = "width:50px;" })
)
</td>
<td>
@(Html.DropDownList("onTransition"+frame.Id,
new SelectList((IEnumerable)ViewData["Transition"], "Value", "Text", @frame.Transition),
new {onclick="LoadImage(this);"})
)
</td>
}
else
{
<td colspan="3">
<textarea rows="1" cols="15" id="Name" name="Name" readonly="true" onclick="display('@frame.Id', this);" style="height:20px">@frame.Name</textarea>
</td>
<td style="display:none;">
@(Html.DropDownList("MyFont", new SelectList((IEnumerable)ViewData["Font"], "Text", "Value", @frame.Font),
new { onclick = "LoadImage(this);", onchange = "LoadImage(this);" }))
</td>
<td style="display:none;">
@(Html.DropDownList("MyColor", new SelectList((IEnumerable)ViewData["Color"], "Text", "Value", @frame.Color),
new { onclick = "LoadImage(this);", onchange = "LoadImage(this);" }))</td>
}
}
我試圖獲得直通一個jQuery命令當前所選行的frame.Id值。 我想讓它在它自身之外。即當頁面上的其他地方點擊提交按鈕時。我已經定義了以下功能:
$(".flashing").click(function() {
var tr = $(this).find(".clickME");
alert(tr.children.length);
});
這個作品 - 在這麼多,因爲我相信我找到我正確的標籤,但不知道它是實際上當前選擇與否的人。對於children.length,我總是得到2的值,但不確定它指向的是什麼。
因此,在上述函數中是否有可能確定(最終)存儲在當前選定標記中的@ frame.Id值。
我對此很陌生,而且這段代碼已經被其他人編寫了,所以我只是想找到自己的方式。
TIA
傑森
嗨達林 不幸的是,我得到一個「不確定」當我嘗試用你有什麼存在。我嘗試了不同的.find排列('input也包含select,但它也不起作用 - 結果相同。移除.val()顯示對象對象,所以我相信它找到了「某些東西」。雖然,米仍然不知道,如果我有多行如何可以找到當前的 - 或者它只是「知道」? 謝謝 – Jason 2011-04-27 08:35:35