vendredi 10 avril 2015

Can't submit a form using DataTables

I have a form and when I remove Datatables, it's working properly. But when I put <table id='example'> to use Datatables, it does not submit the form. If I put echo form_open before ` it doesn't work properly, it inserts only teacher_id=13, but not different for the row, I've chosen. That's my view:





<html>
<head>
<link href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="http://ift.tt/1a9u1Ch"></script>
<script src="http://ift.tt/1rKdStd"></script>
<script src="http://ift.tt/1eNVlIv"></script>
<script src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.js"></script>
<script src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.js">
<script src="../../media/js/dataTables.editor.min.js"></script>

<script>
$(document).ready(function() {
$('#example').dataTable( {
"pagingType": "full_numbers",
"bSort": true,
"sDom": 'T<"clear">lfrtip',
// "pagingType": "scrolling",

"tableTools": {
"sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf",
"aButtons": [
"csv",

{
"sExtends": "pdf",
"sButtonText": "Print PDF",
"mColumns": "visible"
},
"xls"

]
}


} );
} );
</script>
<script>
$(document).ready(function() {

$('#example tfoot th').each( function () {
var title = $('#example thead td').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );


var table = $('#example').DataTable();

table.columns().eq( 0 ).each( function ( colIdx ) {
$( 'input', table.column( colIdx ).footer() ).on( 'keyup change', function () {
table
.column( colIdx )
.search( this.value )
.draw();
} );
} );
} );
</script>
<?php
echo validation_errors();


?>
<table id='example'>
<thead>
<tr>
<th>Teachers</th>
<th>Coord.</th>
<th>Change coord.</th>
<th>Deactivate teacher</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Teachers</th>
<th>Coord.</th>
<th>Change coord.</th>
<th>Deactivate teacher</th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($teachers_show as $teacher)
{
echo form_open('coordinator/deactivate_teacher');
?>
<tr>
<td>
<?php echo $teacher->username;
?>
</td>
<td>
<?php echo $teacher->coordinator_id; ?>
</td><td>
<?php
echo '<a href="edit_coordinator/' . $teacher->user_id . '" class="btn btn-success" id="change_coord"> Change </a>';
?>
</td><td>
<?php
echo "<input type='hidden' name='teacher' value='$teacher->user_id' />";
echo '<input type="submit" name="deactivate" value="Деактивирай учител" id="change_coord" class="btn btn-danger" onclick="return confirm(\'Are you sure you want to deactivate?\'); " />';
?>
</td></tr>
<?php
echo form_close();

}

?>

</tbody>
</table>
</div>
</body>
</html>



Aucun commentaire:

Enregistrer un commentaire