phpでテーブルを出力し、dataTablesで整形しています。
https://datatables.net/
各行に編集ボタンを出力し、クリックすると編集画面が開くという仕様です。
データはtrの無限出力で、jsonは使っていません。
1ページに表示されている編集ボタンは開くのですが、ページング機能を使って2ページ目以降に移動していから編集をクリックしてもイベントが発生せずに困っている状況です。
html
1<table id="dtable"> 2 <thead> 3 <tr> 4 <th>#</th> 5 <th>タイトル</th> 6 <th class="text-right">編集</th> 7 </tr> 8 </thead> 9 <tbody> 10 <tr> 11 <td>1</td> 12 <td>あれこれ</td> 13 <td class="text-right"><button type="button" data-pid="1" class="edit-page"><i class="glyphicon glyphicon-pencil"></i></button></td> 14 </tr> 15 ... 16 </tbody> 17</table>
JavaScript
1$(document).ready(function(){ 2 3 $('#dtable').DataTable({ 4 "dom": 'lCfrtip', 5 "order": [], 6 "colVis": { 7 "buttonText": "表示カラム", 8 "overlayFade": 0, 9 "align": "right" 10 }, 11 "language": { 12 "lengthMenu": '_MENU_ 件づつ表示', 13 "search": '<i class="glyphicon glyphicon-search"></i>', 14 "info": '全_TOTAL_件中 _START_件から_END_件を表示中', 15 "paginate": { 16 "previous": '<i class="glyphicon glyphicon-chevron-left"></i>', 17 "next": '<i class="glyphicon glyphicon-chevron-right"></i>' 18 } 19 } 20 }); 21 $('.edit-page').on('click', function() { 22 var pid = $(this).data('pid'); 23 // 処理 24 }); 25});
1ページ目の編集ボタンには、コンソールでonclickが設定されているのが確認出来ます。
2ページ目以降はコンソールを確認しても確認出来ません。
データはTR垂れ流しなので、1ページ目と2ページ目に差はありません。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/12 06:52