Javascript 数据表赢得';I don’我不能在模态中工作
我有一个表,在其中的行上单击打开一个模式窗口。多亏了这一点:Javascript 数据表赢得';I don’我不能在模态中工作,javascript,jquery,spring,datatables,thymeleaf,Javascript,Jquery,Spring,Datatables,Thymeleaf,我有一个表,在其中的行上单击打开一个模式窗口。多亏了这一点: th:onclick="'javascript:openPoolModal(\''+ ${networkHashrate.id} + '\');'" openPoolModal.js看起来像: function openPoolModal(id){ $.ajax({ url: "/" + id, success: function(data){ $("#PoolModalHolder").html(data
th:onclick="'javascript:openPoolModal(\''+ ${networkHashrate.id} + '\');'"
openPoolModal.js
看起来像:
function openPoolModal(id){
$.ajax({
url: "/" + id,
success: function(data){
$("#PoolModalHolder").html(data);
$("#personalModal").modal();
$("#personalModal").modal('show');
}
});
}
PoolModalHolder
只是我的main.html
文件中的一个空div,其中呈现了第一个表personalModal
是在模式对话框中打开的代码片段
然后,模式对话框中会充满personalModal
:
<div class="modal fade" id="personalModal" role="dialog" th:fragment="modalContents">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title" th:text="'Network Id: ' + ${poolHashrates[0].networkHashrate.id}">Network Id</h4>
</div>
<div class="modal-body">
<div class="table-responsive">
<table width="100%" class="table table-hover " id="poolTable">
<thead class="thead-inverse">
<tr>
<th class="col-md-2 text-center">Pool name</th>
<th class="col-md-2 text-center">Date from</th>
<th class="col-md-2 text-center">Hashrate</th>
</tr>
</thead>
<tbody>
<tr th:each="poolHashrate : ${poolHashrates}">
<td class="text-center" th:text="${poolHashrate.poolDef.name}"> Sample data</td>
<td class="text-center" th:text="${poolHashrate.poolDef.date_from}">Maven Street 10, Glasgow</td>
<td class="text-center" th:text="${poolHashrate.hashrate}">999-999-999</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
我也尝试过这一点,但结果相同:
$( "#personalModal" ).focus(function() {
$('#poolTable').DataTable();
});
我添加了标题链接,它们是:jQuery、Bootstrap、DataTables.js
我也尝试了
表响应的示例,但同样不起作用。通过Spring控制器方法正确生成数据。我只需要对表应用排序和分页。当您说它不起作用时,是否有控制台错误?是否可以从控制台或模式页面上的任何其他元素访问该表的jQuery选择器?是否尝试了('show.bs.modal',function(){$('poolTable').DataTable();})
?
$( "#personalModal" ).focus(function() {
$('#poolTable').DataTable();
});