jquery - 如何使用引导模型对话框将数据添加到数据表?
问题描述
如何使用模型对话框动态地将数据添加到 jquery 数据表而不在 mvc 中保存和返回视图?
<button type="button" class="btn btn-default btn-md" data-toggle="modal" data-url="@Url.Action("Create","POPM_Trn_IOU_Items")" id="btnCreateAsset">
<span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> Add Asset
</button>
<div class="glyphicon-modal-window" id="createAssetModal" tabindex="-1" role="dialog" aria-labelledby="CreateAssetModal" aria-hidden="true" data-backdrop="static">
<div id="createAssetContainer">
</div>
</div>
@*<table id="example" class="table table-striped table-bordered" cellspacing="0">*@
<thead>
<tr>
<th>Item</th>
<th>Unit</th>
<th>Quantity</th>
<th>Cost</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if (Model.IouItems != null)
{
foreach (var item in Model.IouItems)
{
<tr>
<td></td>
<td style="text-align:center">
@Html.DisplayFor(modelItem => item.POPM_Item_ItemName)
</td>
<td style="text-align:center">
@Html.DisplayFor(modelItem => item.POPM_Item_ItemUnit)
</td>
<td style="text-align:center">
@Html.DisplayFor(modelItem => item.POPM_Item_Quantity)
</td>
<td style="text-align:center">
@Html.DisplayFor(modelItem => item.POPM_Item_ItemCost)
</td>
<td style="text-align:center">
@Html.DisplayFor(modelItem => item.Item_ID)
</td>
</table>
</div>
JS `$(document).on('click', '#btnCreateAsset', function () { var url = $(this).data("url"); $.get(url, function(data) { $( '#createAssetContainer').html(数据);
event.preventDefault();
jQuery.noConflict();
var myBookId = $(this).data('k');
$(".modal-body #a").val(myBookId);
$('#createAssetModal').modal('show');
});
});``
解决方案
推荐阅读
- java - XMLStreamReader 无法读取其中包含换行符的字段,而是取最后一行
- c# - 具有多个参数的 xamarin 命令
- c++ - struct object 在 main 函数中在哪里获取内存?
- java - Google 协议缓冲区未在构建器中设置值
- r - lubridate:解析“27.10.2013 02A:00”形式的日期(夏令时)
- scala - 断言返回类型为 Future[Unit] 的 scala 方法的最佳方法是什么
- php - 传递给 __construct() 的参数 1 必须是 GuzzleHttp\Client 的实例
- fortran - Fortran - 跳转其他子程序
- r - 排序时使用'arrange()'时如何获取Dataframe的行名
- javascript - Chart.js 工具提示中只有正值