Reputation: 15
Hi i have a problem here in my datatable (http://www.datatables.net/) here's my code.
enter code here
<table id="example" width="100%" border="0" class="display" >
<thead>
<tr align="center">
<th>Function</th>
<th>Location Name</th>
<th>Route Id</th>
<th>Stops</th>
<th>Cbm</th>
<th>Tons</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<?php
if(isset($load)>0){
$id = 0;
foreach($load as $key => $load){
$id++;
?>
<tr >
<td>
<img **class="pencil_edit"** title="edit" src = "<?php echo base_url()."application/kookabura/images/pencil.png"; ?>">
</td>
<td><?php echo $load['name'];?></td>
<td><?php echo $load['route_id'];?></td>
<td><?php echo $load['stops'];?></td>
<td><?php echo $load['cbm'];?></td>
<td><?php echo $load['tons'];?></td>
</tr>
<?php }
}
if(isset($_POST['date']) == ''){
$date = date('Y-m-d');
}else{
$date = $_POST['date'];
}
?>
</tbody>
</table>
now i have a function in javascript that is look like this the first 10 records can call this function but after i search for the next record for example record number 11 or after is sort the table it doesn't work. any idea? Tnx so much for the help hope you can understand what im saying here :D
$( ".pencil_edit" )
.click(function() {
alert('hello');
});
Upvotes: 0
Views: 105
Reputation: 3855
If you are using AJAX then do as following way
For jQuery 1.8 or above
$( document ).on('click', ".pencil_edit", function() {
alert('hello');
});
For jQuery 1.7 or below
$( ".pencil_edit" ).live( "click", function() {
alert( "Goodbye!" ); // jQuery 1.3+
});
Upvotes: 1