1
我遇到了一些CakePHP序列化和引導表的麻煩。 我已經載入全部.js
。 我認爲引導表不要重新調整 { "despesas":[
.json
有人可以幫我嗎?CakePHP引導表故障
我route.php
//code
Router::extensions(['json']);
//code
我DespesasController.php功能
//code
public function test()
{
$this->paginate = [
'contain' => ['Lojas', 'DespesaTipos'],
'limit' => '1000000000'
];
$this->set('despesas', $this->paginate($this->Despesas));
$this->set('_serialize', ['despesas']);
}
//code
test.ctp
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.css">
<table id="table"></table>
<!-- Latest compiled and minified JavaScript -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/locale/bootstrap-table-pt-BR.min.js"></script>
<script type="text/javascript">
$('#table').bootstrapTable({
url: 'test.json',
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'descricao',
title: 'Item Name'
}, {
field: 'valor',
title: 'Item Price'
}, ]
});
</script>
test.json
{
"despesas": [
{
"id": 1,
"data": "2015-01-02T00:00:00-0200",
"descricao": "INTERNET TRIBUNA BAIRROS (50%)",
"valor": 1503,
"loja_id": 1,
"despesa_tipo_id": 1,
"obs": "",
"created": "2015-12-10T00:00:00-0200",
"modified": "2015-08-05T00:00:00-0300",
"criado_por": "Kelvin Primo",
"modificado_por": "Deise"
},
當我打開它在瀏覽器返回。
No matching records found
Uncaught TypeError:$(...)。bootstrapTable不是函數。控制檯命令。 –
https://jsfiddle.net/L0qkbxcd/1/ –
哦,確保你的代碼在$(function(){CODE_HERE})內;否則它將在您的腳本加載之前運行。 –