0
我開始在一家新公司工作,他們有這個工具來管理公司的不同方面。他們使用php中的symfony框架和一個名爲DataTables的jquery插件來顯示錶格。在這個項目中,他們使用了一個table.js.twig,它應該使用表ID爲整個站點中的表格提供一定的格式。我的問題ID如何實現這種文件。我一直在尋找關於這種文件的信息,但我只找到關於html.twig的信息。如何使用或加載xxx.js.twig文件
the tables.js.twig:
$(function() {
.
.
.
$('#id1').dataTable({
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false
});
$('#id2').dataTable({
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false
});
.
.
.
});
在base.html.twig腳本部分:
<script type="text/javascript">
$(document).ready(function() {
$('.summernote').summernote({
height: 500, // set editor height
minHeight: null, // set minimum height of editor
maxHeight: null, // set maximum height of editor
focus: true, // set focus to editable area after initializing summernote
});
//Here is where all the .dataTables should go.
});
</script>
,如果我在腳本部分全部.dataTable它直接寫,但他們是一個很大的,其應該是在一個樹枝文件,使其更具可讀性,但我不知道如何工作。
這是我的第一個問題,我用這個作爲最後一個資源。如果你能幫助我,我會非常感激。
編輯
這是我的文件夾中的分佈
/app
/Resources
/views
/base.html.twig
/src
/Company
/Bundle
/OfficeBundle
/Resources
/views
/User
/allUser.html.twig **Where I display the tables
/Structure
/tables.js.twig
對於一個動作,你可以使用你喜歡的任何模板:'@Template(「SensioBlogBundle:Post:dataTable.js.twig」)''。你的數據表從哪裏來?然後,你可以用'
這裏是我會做什麼:
在你的HTML添加
而在你的樹枝上,你可以實現你想要建立你的表格的邏輯
我不知道它是否違背了良好的做法。
來源
2016-02-25 15:50:46 Hakim
謝謝你的回答,但是我的項目太棒了,我需要在很多地方做到這一點,我認爲必須有一個更簡單的方法來實現這一目標。還是謝謝:) – OmarAguinaga
我發現了問題,我使用了Salenix的解決方案。問題是在路徑,我不得不做以下,以使參考:
首先要爲文檔塊準備好,然後做什麼Salenix建議,最後我不得不做出參考與@和捆綁。
感謝您的幫助。
來源
2016-02-29 10:42:24 OmarAguinaga