2016-04-22 9 views
0

データテーブルをGridRowCount()と共に使用して、htmlテーブルの指定されたグループで行数を取得すると、jfiddleサイトはhereになります。コードを実行すると、クロムブラウザはキャッチされていないタイプのエラー(...)をスローします。ライブは関数ではありません。データ型キャッチした型のエラー


コンソールからのエラーが表示されます。以下

rowtoggle.js:30 Uncaught TypeError: $(...).live is not a function 
 
rowtoggle.js:30 Uncaught TypeError: $(...).live is not a functionGridRowCount @ rowtoggle.js:30(anonymous function) @ rowtoggle.js:16i @ jquery-1.12.2.min.js:2j.fireWith @ jquery-1.12.2.min.js:2n.extend.ready @ jquery-1.12.2.min.js:2K @ jquery-1.12.2.min.js:2 
 
Navigated to http://localhost/datacentre/admin/request_pending.php 
 
rowtoggle.js:30 Uncaught TypeError: $(...).live is not a functionGridRowCount @ rowtoggle.js:30(anonymous function) @ rowtoggle.js:16i @ jquery-1.12.2.min.js:2j.fireWith @ jquery-1.12.2.min.js:2n.extend.ready @ jquery-1.12.2.min.js:2K @ jquery-1.12.2.min.js:2 
 
Navigated to http://localhost/datacentre/admin/request_pending.php


のDataTableのコードとGroupRowCount()plugginあります。

$(document).ready(function() { 
 
\t \t \t $('#example').dataTable({ 
 
\t \t \t \t 
 
\t \t  \t "bLengthChange": false, 
 
       "bPaginate": false, 
 
       "bJQueryUI": true \t \t \t \t 
 
\t \t \t }).rowGrouping({ 
 
     iGroupingColumnIndex: 1, 
 
     \t sGroupingColumnSortDirection: "asc", 
 
     \t iGroupingOrderByColumnIndex: 0 , 
 
\t \t bExpandableGrouping: true, 
 
     bExpandSingleGroup: false, 
 
     iExpandGroupOffset: -1, 
 
     asExpandedGroups: [""] 
 
    }); 
 
\t GridRowCount(); 
 
}); 
 

 
function GridRowCount() { 
 
      $('span.rowCount-grid').remove(); 
 
      $('input.expandedOrCollapsedGroup').remove(); 
 

 
      $('.dataTables_wrapper').find('[id|=group-id]').each(function() { 
 
       var rowCount = $(this).nextUntil('[id|=group-id]').length; 
 
       $(this).find('td').append($('<span />', { 'class': 'rowCount-grid' }).append($('<b />', { 'text': rowCount }))); 
 
      }); 
 

 
      $('.dataTables_wrapper').find('.dataTables_filter').append($('<input />', { 'type': 'button', 'class': 'expandedOrCollapsedGroup collapsed', 'value': 'Expanded All Group' })); 
 

 
      **$('.expandedOrCollapsedGroup').live('click', function() { 
 
       if ($(this).hasClass('collapsed')) {** 
 
        $(this).addClass('expanded').removeClass('collapsed').val('Collapse All Group').parents('.dataTables_wrapper').find('.collapsed-group').trigger('click'); 
 
       } 
 
       else { 
 
        $(this).addClass('collapsed').removeClass('expanded').val('Expanded All Group').parents('.dataTables_wrapper').find('.expanded-group').trigger('click'); 
 
       } 
 
      }); 
 
     };

答えて

3

.live()のjQuery 1.7で非推奨とバージョン1.9で削除されました。あなただけの補正を行って.on()

$('.expandedOrCollapsedGroup').on('click', function() { 
//Your code 
}) 
+0

感謝を使用する必要があります –