[英]Clicking Bootstrap Input Button in List Disables Other Buttons
This project uses Twitter Bootstrap, and a page lists saved files for either retrieval or deletion. 该项目使用Twitter Bootstrap,页面列出了用于检索或删除的已保存文件。 If the user clicks a "Download" input button in the list, other files' "Download" button clicks don't fire.
如果用户单击列表中的“下载”输入按钮,则不会触发其他文件的“下载”按钮单击。 How can the buttons be set up such that a user can just go down the line and download each file one after the other?
如何设置按钮,以便用户可以直接下载并逐个下载每个文件?
I've tried setting the button id to enabled or active at the end of the download script, but that hasn't worked. 我已经尝试在下载脚本结束时将按钮ID设置为启用或激活,但这没有用。 Does anyone see what's going on here?
有谁看到这里发生了什么? Thanks in advance!
提前致谢!
List in View: 列表视图:
<div class="panel panel-default" id="uploadPanel">
<div class="panel-heading">Uploaded Files</div>
<div class="panel-body">
<table id="dt_basic" class="table table-striped">
<thead>
<tr>
<th style="display:none"></th>
<th class="text-center">File Name</th>
<th class="text-center">Uploaded Date</th>
<th class="text-center">Uploaded By</th>
<th></th>
</tr>
</thead>
<tbody>
@if (Model.UploadedFiles.Any())
{
foreach (var record in Model.UploadedFiles)
{
<tr>
<td style="display:none">@record.UploadedFileID</td>
<td align="center">@record.UploadedFileName</td>
<td align="center">@String.Format("{0:d}", @record.UploadedFileDate)</td>
<td align="center">@record.UploadedBy</td>
<td align="center"><input type="button" class="btn btn-info" id="downloadFile" value="Download"> | <input type="button" class="btn btn-warning" id="deleteFile" value="Delete"></td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
The script for downloading a file: 下载文件的脚本:
$("#downloadFile").click(function () {
var cells = $(this).closest('tr').children('td');
var $id = Number(cells.eq(0).text());
var $url = '@Url.Action("DownloadFile", "Files", new { id = "_id_" })';
document.location.href = $url.replace("_id_", $id);
//Tried re-activating and re-enabling $("downloadFile") here, but to no avail
});
Do it by class
assign as opposed to id
通过
class
分配而不是id
<td align="center"><input type="button" class="btn btn-info downloadFile" value="Download"> | <input type="button" class="btn btn-warning deleteFile" value="Delete"></td>
$(".downloadFile").click(function () {
var cells = $(this).closest('tr').children('td');
var $id = Number(cells.eq(0).text());
var $url = '@Url.Action("DownloadFile", "Files", new { id = "_id_" })';
document.location.href = $url.replace("_id_", $id);
//Tried re-activating and re-enabling $("downloadFile") here, but to no avail
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.