我需要始终使用jquery列出数据表中最后的最后一条记录。
目前是这样的。
因为每当我添加一个新项目时,第一个总是出现,用jquery将这种模式适合我的数据表的最佳方法是什么
DATATABLE
`<table id="na_datatable" class="table table-hover dashboard-task-infos">
<thead>
<tr>
<th>id</th>
<th>Bairro</th>
<th>Categoria</th>
<th>Apartamento</th>
<!--<th>Dormitórios</th>
<th>Box</th>
<th>Mobiliado</th>
<th>Chaves</th>
<th>Proprietário</th>
<th>Contato</th>
<th>Valor</th>-->
<th>Cadastrado em</th>
<th>Atualizado em</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<?php foreach ($ci_properties as $properties) : ?>
<tr>
<th><?= $properties['propertie_id'] ?></th>
<th><?= $properties['bairro'] ?></th>
<th><?= $properties['empreendimento'] ?></th>
<th><?= $properties['apartamento'] ?></th>
<!--<th><?= $properties['dormitorios'] ?></th>
<th><?= $properties['box'] ?></th>
<th><?= $properties['mobiliado'] ?></th>
<th><?= $properties['chaves'] ?></th>
<th><?= $properties['proprietario'] ?></th>
<th><?= $properties['contato'] ?></th>
<th><?= $properties['valor'] ?></th>-->
<th><?= $properties['cadastro'] ?></th>
<th><?= $properties['atualizado'] ?></th>
<th>
<div><a title="View" class="view btn btn-sm btn-info pull-left" data-id="<?= $properties['propertie_id'] ?>" data-toggle="modal" data-target="#view-property"> Visualizar <i class="material-icons">visibility</i></a></div>
</th>
</tr>
<?php endforeach ?>
</tbody>
<thead>
<tr>
<th>id</th>
<th>Bairro</th>
<th>Categoria</th>
<th>Apartamento</th>
<!--<th>Dormitórios</th>
<th>Box</th>
<th>Mobiliado</th>
<th>Chaves</th>
<th>Proprietário</th>
<th>Contato</th>
<th>Valor</th>-->
<th>Cadastrado em</th>
<th>Atualizado em</th>
<th>Ações</th>
</tr>
</thead>
</table>
`
JQUERY
<!-- Jquery DataTable Plugin Js -->
<script src="<?= base_url()?>public/plugins/jquery-datatable/jquery.dataTables.js"></script>
<script src="<?= base_url()?>public/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js"></script>
<script type="text/javascript">
window.properties = <?= json_encode($ci_properties) ?>;
$(document).ready( function () {
$('#na_datatable').DataTable();
$('body').on('click','.btn.view',function(e){
var id = $(e.target).closest('.btn.view').data("id");
var property = window.properties.find(p => p.propertie_id == id);
$('#view-property .modal-body').html('');
$('#view-property .modal-title .propertie-id').html(property.propertie_id);
$('#view-property .modal-body').append(`<div><b>Bairro:</b> ${property.bairro}</div>`);
$('#view-property .modal-body').append(`<div><b>Empreendimento:</b> ${property.empreendimento}</div>`);
$('#view-property .modal-body').append(`<div><b>Apartamento:</b> ${property.apartamento}</div>`);
$('#view-property .modal-body').append(`<div><b>Dormtirórios:</b> ${property.dormitorios}</div>`);
$('#view-property .modal-body').append(`<div><b>Box:</b> ${property.box}</div>`);
$('#view-property .modal-body').append(`<div><b>Mobiliado:</b> ${property.mobiliado}</div>`);
$('#view-property .modal-body').append(`<div><b>Chaves:</b> ${property.chaves}</div>`);
$('#view-property .modal-body').append(`<div><b>Proprietario:</b> ${property.proprietario}</div>`);
$('#view-property .modal-body').append(`<div><b>Contato:</b> ${property.contato}</div>`);
$('#view-property .modal-body').append(`<div><b>Valor:</b> ${property.valor}</div>`);
$('#view-property .modal-body').append(`<div><b>Cadastro:</b> ${property.cadastro}</div>`);
$('#view-property .modal-body').append(`<div><b>Atualizado:</b> ${property.atualizado}</div>`);
});
} );
</script>