I have this sample page created that uses Jquery datatable within that I'm using <apex:actionsupport>
and when I click on the hyperlink for that particular column it does not fire the event and the way I'm testing is that when the user clicks on the a href
it fires the action method on the controller and I'm spitting the system.debug
just to make sure it does calling this method. When I looked at the log it does not show that action method fires, what I'm doing wrong here?
Markup:
<apex:form id="myform">
<head>
<apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
<apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
<apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />
<script>
j$ = jQuery.noConflict();
j$(document).ready( function () {
var tbl = j$('[id$="tbl"]').DataTable({
//for empty
"columnDefs": [{
"defaultContent": "empty",
"targets": "_all"
}]
});
});
</script>
</head>
<table class="table table-striped table-hover" id="tbl" >
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!myData}" var="t" id="reg">
<tr>
<td>
<apex:actionsupport action="{!loadDataById}" event="onclick" rerender="pb2" >
<a href="#"><apex:param name="selectedId" value="{!t.Id}">{!t.Name}</apex:param></a>
</apex:actionsupport>
</td>
<td>{!t.description} </td>
</tr>
</apex:repeat>
</tbody>
</table>
<br/>
<apex:pageblock id="pb2 ...>
{!SecondList}
</apex:pageblock>
</apex:form>
Controller:
public List<my_custom_object> secondList { get; set; }
public void loadDataById()
{
String selectedId = System.currentPagereference().getParameters().get('selectedId');
List<my_custom_object> myDataList = [SELECT ...];
system.debug('selectedid: ' + selectedId);
secondList = myDataList ;
}
apex:outputLink
instead of plaina
tag? See if it works..