2015-05-14 95 views
-2

我想implmenting數據表,但它是給錯誤:遺漏的類型錯誤:未定義不是一個功能 - 數據表

遺漏的類型錯誤:$(...)數據表上不是一個函數

的我試圖代碼:

<script type="text/javascript" src="../assets/styles/components/data-tables/jquery.dataTables.js"></script> 
<script type="text/javascript" src="../assets/styles/components/data-tables/DT_bootstrap.js"></script> 
<script> 
$(document).ready(function() { 
    $('#sample_1').dataTable({ 
     "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>", 
     "sPaginationType": "bootstrap", 
     "oLanguage": { 
      "sLengthMenu": "_MENU_ records per page", 
      "oPaginate": { 
       "sPrevious": "Prev", 
       "sNext": "Next" 
      } 
     }, 
     "aoColumnDefs": [{ 
      'bSortable': false, 
      'aTargets': [0] 
     }] 
    }); 
    jQuery('#sample_1 .group-checkable').change(function() { 
     var set = jQuery(this).attr("data-set"); 
     var checked = jQuery(this).is(":checked"); 
     jQuery(set).each(function() { 
      if (checked) { 
       $(this).attr("checked", true); 
      } else { 
       $(this).attr("checked", false); 
      } 
     }); 
     jQuery.uniform.update(set); 
    }); 
    jQuery('#sample_1_wrapper .dataTables_filter input').addClass("form-control"); 
    jQuery('#sample_1_wrapper .dataTables_length select').addClass("form-control"); 
}); 
</script> 

這裏是我的html代碼:

<table cellpadding="0" cellspacing="0" border="0" class="table table-striped border-top" id="sample_1"> 
       <thead> 
        <tr> 
        <th>No.</th> 
        <th>Date</th> 
        <th>Time</th> 
        <th>Contract</th> 
        <th>Deposit</th> 
        <th>Price</th> 
        <th>Buy # of Contracts</th> 
        <th>Sell # of Contracts</th> 
        <th>P&amp;L </th> 
        <th>Expiry Time</th> 
        <th>Settlement Payout</th> 
        <th>Fee Payment</th> 
        <th>Sell to Close</th> 
        <th>Buy to Close</th> 
        </tr> 
       </thead> 
       <tbody> 
<tr class="odd gradeX"> 
    <td>1</td> 
    <td>04-01-2015</td> 
    <td>09:33 AM</td> 
    <td>EUR/JPY </td> 
    <td></td> 
    <td>118</td> 
    <td></td> 
    <td>2</td> 
    <td>-118</td> 
    <td>3PM</td> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td></td> 
</tr> 
<tr class="odd gradeX"> 
    <td>2</td> 
    <td>04-01-2015</td> 
    <td>09:33 AM</td> 
    <td>EUR/JPY </td> 
    <td></td> 
    <td>118</td> 
    <td></td> 
    <td>2</td> 
    <td>-1.8</td> 
    <td>3PM</td> 
    <td></td> 
    <td>-1.8</td> 
    <td></td> 
    <td></td> 
</tr> 
<tr class="odd gradeX"> 
    <td>3</td> 
    <td>04-01-2015</td> 
    <td>09:43 AM</td> 
    <td>EUR/JPY </td> 
    <td></td> 
    <td>80</td> 
    <td></td> 
    <td>2</td> 
    <td>80</td> 
    <td>3PM</td> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td>80</td> 
</tr> 
<tr class="odd gradeX"> 
    <td>4</td> 
    <td>04-01-2015</td> 
    <td>09:43 AM</td> 
    <td>EUR/JPY </td> 
    <td></td> 
    <td>80</td> 
    <td></td> 
    <td>2</td> 
    <td>-0.9</td> 
    <td>3PM</td> 
    <td></td> 
    <td>-0.9</td> 
    <td></td> 
    <td></td> 
</tr> 
<tr class="odd gradeX"> 
    <td>5</td> 
    <td>04-01-2015</td> 
    <td>09:45 AM</td> 
    <td>EUR/JPY </td> 
    <td></td> 
    <td>80</td> 
    <td></td> 
    <td>2</td> 
    <td>80</td> 
    <td>3PM</td> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td>80</td> 
</tr> 
<tr class="odd gradeX"> 
    <td>6</td> 
    <td>04-01-2015</td> 
    <td>09:45 AM</td> 
    <td>EUR/JPY </td> 
    <td></td> 
    <td>80</td> 
    <td></td> 
    <td>2</td> 
    <td>-0.9</td> 
    <td>3PM</td> 
    <td></td> 
    <td>-0.9</td> 
    <td></td> 
    <td></td> 
</tr> 
<tr class="odd gradeX"> 
    <td>7</td> 
    <td>04-01-2015</td> 
    <td>10:28 PM</td> 
    <td>AUD/USD </td> 
    <td></td> 
    <td>111.5</td> 
    <td>2</td> 
    <td>2</td> 
    <td>-88.5</td> 
    <td>11AM</td> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td></td> 
</tr> 
<tr class="odd gradeX"> 
    <td>8</td> 
    <td>04-01-2015</td> 
    <td>10:28 PM</td> 
    <td>AUD/USD </td> 
    <td></td> 
    <td>111.5</td> 
    <td>2</td> 
    <td>2</td> 
    <td>-1.8</td> 
    <td>11AM</td> 
    <td></td> 
    <td>-1.8</td> 
    <td></td> 
    <td></td> 
</tr> 
<tr class="odd gradeX"> 
    <td>9</td> 
    <td>04-21-2015</td> 
    <td>01:00 PM</td> 
    <td></td> 
    <td>5000</td> 
    <td>0</td> 
    <td>2</td> 
    <td>2</td> 
    <td>5000</td> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td></td> 
</tr> 
     </tbody> 
    </table> 
+0

不熟悉的庫,但文件表明,它是'.DataTable'大寫D. – JJJ

+0

哪裏是HTML代碼? –

+0

@Juhana它是'.DataTable()'在[本網站](https://www.datatables.net)上,但它是'.dataTable()'[here](https://github.com/DataTables /數據表)。誰知道OP使用什麼... – Regent

回答

0

改變

$('#sample_1').dataTable 

我試圖解決方案的數量後,終於解決了我的問題。

問題是我使用錯誤的層次結構將文件放在另一個文件上。

所以,首先它不是問題,也不是插件集成,而是一個接一個地正確排序文件。

這是我的代碼的最終輸出:

<!-- javascripts --> 
<script src="../assets/styles/js/jquery.js"></script> 
<script src="../assets/styles/js/jquery-1.8.3.min.js"></script> 
<script type="text/javascript" src="../assets/styles/js/jquery-ui-1.9.2.custom.min.js"></script> 

<!-- bootstrap --> 
<script src="../assets/styles/js/bootstrap.min.js"></script> 
<!-- nice scroll --> 
<script src="../assets/styles/js/jquery.scrollTo.min.js"></script> 
<script src="../assets/styles/js/jquery.nicescroll.js" type="text/javascript"></script> 
<script src="../assets/styles/jquery-knob/js/jquery.knob.js"></script> 
<script src="../assets/styles/js/jquery.sparkline.js" type="text/javascript"></script> 
<script src="../assets/styles/components/jquery-easy-pie-chart/jquery.easy-pie-chart.js"></script> 
<script src="../assets/styles/js/owl.carousel.js" ></script> 

<!-- jQuery full calendar --> 
<script src="../assets/styles/components/fullcalendar/fullcalendar/fullcalendar.min.js"></script> 

<!--script for this page only--> 
<script src="../assets/styles/js/calendar-custom.js"></script> 

<!-- custom select --> 
<script src="../assets/styles/js/jquery.customSelect.min.js" ></script> 

<!--custome script for all page--> 
<script src="../assets/styles/js/scripts.js"></script> 

<!-- custom script for this page--> 
<script src="../assets/styles/js/sparkline-chart.js"></script> 
<script src="../assets/styles/js/easy-pie-chart.js"></script> 
<script type="text/javascript" src="../assets/styles/components/data-tables/jquery.dataTables.js"></script> 
<script type="text/javascript" src="../assets/styles/components/data-tables/DT_bootstrap.js"></script> 
<script> 
$(document).ready(function() { 
     $('#sample_1').dataTable({ 
      "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>", 
      "sPaginationType": "bootstrap", 
      "oLanguage": { 
       "sLengthMenu": "_MENU_ records per page", 
       "oPaginate": { 
        "sPrevious": "Prev", 
        "sNext": "Next" 
       } 
      }, 
      "aoColumnDefs": [{ 
       'bSortable': false, 
       'aTargets': [0] 
      }] 
     }); 
     jQuery('#sample_1 .group-checkable').change(function() { 
      var set = jQuery(this).attr("data-set"); 
      var checked = jQuery(this).is(":checked"); 
      jQuery(set).each(function() { 
       if (checked) { 
        $(this).attr("checked", true); 
       } else { 
        $(this).attr("checked", false); 
       } 
      }); 
      jQuery.uniform.update(set); 
     }); 
     jQuery('#sample_1_wrapper .dataTables_filter input').addClass("form-control"); 
     jQuery('#sample_1_wrapper .dataTables_length select').addClass("form-control"); 
    }); 
</script> 
-4

嘗試通過

jQuery('#sample_1').dataTable 
+0

如果'$'被重新分配,它會在'$(document).ready()'前面拋出一個錯誤。 – JJJ

+0

你是對的,我沒看到那條線 –

相關問題