I've searched around and for something so easy I can't find a solution that works for me. I have a table object with an ID. I'm using JQuery to grab the ID on the clicked object and want to pass it my datasource, but i'm not able to. Can someone help me out?
HTML:
<a href="#" data-toggle="modal" data-target="#clusterpulse" id="cluster1">cluster1</a>
JavaScript:
<script>
$("table").delegate("a", "click", function() {
id2=$(this).attr('id');
});
$('#cluster_pulse_table').dataTable( {
"bprocessing": true,
"bserverSide": true,
"sAjaxSource": "../scripts/cluster_pulse.php?val=" + id2,
} );
</script>
Well you can change delegate with on
$("table").on("click", "a", function() {
var id2 = $(this).attr('id');
$('#cluster_pulse_table').dataTable( {
"bprocessing": true,
"bserverSide": true,
"sAjaxSource": "../scripts/cluster_pulse.php?val=" + id2,
});
});
And you need to call dataTable after you have the id2 value. As you had it dataTable was called without it, so that could be one place for an error.