How to make 2 buttons working with different links in a custom static column
How to make 2 buttons working with different links in a custom static column
metilic
Posts: 3Questions: 1Answers: 0
i'm struggeling to make a static column with 2 buttons that trigger 2 links with dinamic data. I managed to make 1 button work but i can't make the other. I tryed adding an id to each one and call different functions for each one but it seems it's only working with $('#example tbody ')
and not ($('#customID')
.So my question is how can i trigger delete button with different link. Here is my js:
<script type="text/javascript">
$(document).ready(function() {
var table = $('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "app/server_processing.php",
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button>Edit</button> <button>Delete</button>"
} ]
} );
$('#example tbody ').on( 'click', 'button', function () {
var data = table.row( $(this).parents('tr') ).data();
window.location.href = "index.php?categ=edit&id="+ data[0];
} );
} );
</script>
This discussion has been closed.
Answers
nvm i fixed it