2015-02-23 40 views
1

我想知道如何在复制按钮之前添加一个按钮,该按钮始终是链接到资源的创建页面的链接。因此,如果它在用户/用户和按钮列表中,如果用户单击添加,则它将转到/ users/create。我将如何用下面的代码来做到这一点。我也有一些错误和研究,发现我的错误可能是由于我的文件呈现的顺序。我已经包含了下面的命令。我希望有人能以某种方式帮助我。使用数据表修改TableTools

TypeError: jQuery[g3g][((((Y2 + Z3) + G4) + p1) + F9e)] is undefined 


...((Y2+G4+d6g+Z3+G4+A1e+U2+y8g))):jQuery&&!jQuery[g3g][(Y2+Z3+G4+p1+F9e)][(y8+t5e+... 


dataTab...itor.js (line 475, col 170) 
TypeError: DataTable.Editor is undefined 


DataTable.Editor.defaults.display = "bootstrap"; 

editor....trap.js (line 8) 


$('document').ready(function() { 
    $('#myDatatable').dataTable({ 
     "pagingType": "full_numbers", 
     "aoColumnDefs": [ 
      { 'bSortable': false, 'aTargets': [-1] }, 
      { 'sWidth': '30px', 'aTargets': ['idTH'] }, 
      { 'sWidth': '150px', 'aTargets': ['actionsTH', 'subTH'] }, 
      { 'sClass': 'text-center', 'aTargets': ['idTH', 'actionsTH', 'subTH'] } 
     ], 
     "iDisplayLength": 10, 
     "aLengthMenu": [ 
      [5, 10, 25, 50, -1], 
      [5, 10, 25, 50, "All"] 
     ], 
     dom: '<"dt-panelmenu clearfix"Tfr>t<"dt-panelfooter clearfix"ip>', 
     "oTableTools": { 
      "sSwfPath": "vendor/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf" 
     } 
    }); 
}); 

<script src="http://myapp.app/vendor/jquery/jquery-1.11.1.min.js"> 
<script src="http://myapp.app/vendor/jquery/jquery_ui/jquery-ui.min.js"> 
<script src="http://myapp.app/assets/js/bootstrap/bootstrap.min.js"> 
<script src="http://myapp.app/assets/js/utility/utility.js"> 
<script src="http://myapp.app/assets/js/main.js"> 
<script type="text/javascript"> 
<script src="http://myapp.app/vendor/plugins/datatables/media/js/jquery.dataTables.js"> 
<script src="http://myapp.app/vendor/plugins/datatables/media/js/dataTables.bootstrap.js"> 
<script src="http://myapp.app/vendor/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.min.js"> 
<script src="http://myapp.app/vendor/plugins/datatables/extensions/Editor/js/dataTables.editor.js"> 
<script src="http://myapp.app/vendor/plugins/datatables/media/js/dataTables.bootstrap.js"> 
<script src="http://myapp.app/vendor/plugins/datatables/extensions/Editor/js/editor.bootstrap.js"> 
<script src="http://myapp.app/assets/js/my-datatables.js"> 
+0

这样的事情https://datatables.net/forums/discussion/20149/sbuttontext-not-working-when-extending-editor-create。欢呼 – 2015-02-24 07:39:29

+0

我更新了我的帖子,因为我仍然不确定如何处理上述问题。 – user3732216 2015-02-28 18:16:58

回答

2

好的一个,在你的<script>标签部分,你打开一个标签,但从不关闭它。这可能是你没有定义的奇怪错误。与其脚本的位置和顺序无关。

至于为您的用户界面添加一个按钮,有时候数据表可以解释它,它并不总是对您有利,对那些用户来说更是如此按钮是基于闪光的。您的来电$('#myDatatable').dataTable({});

简单地通过附加标准jQuery方法的元素..

即:

我愿意为例子来说说

$('#myDatatable').append('<div style="width:100px;height:30px;background-color:#F60;color:#fff;position:absolute;top:2px;right:275px;">Hello</div>'); 

同样主要用于举例来说,您可以根据需要进行调整,但基本上可以将这个按钮紧贴在这些按钮旁边,如果您喜欢,您可能会将它放入按钮容器中,但是随后您会因为额外的样式而陷入混乱,如果你总体感觉到事情的话,最容易去旁边。