unable to call click on class selector when element is formatted by 'fnRowCallback'
unable to call click on class selector when element is formatted by 'fnRowCallback'
Hi,
I'm a beginner using datatables for my application. I'm trying to format data in a table to expand and contract content which is having comma seperated values. I'm trying to do the formatting using "fnRowCallback" like below:
[code]
oTable = $('#searchResultsTable').dataTable( {
"bStateSave" : true,
"sPaginationType" : "full_numbers",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(0)', nRow).html( 'View');
if(aData[5].indexOf(",") != -1) {
$('td:eq(5)', nRow).html( ''+aData[5]+'');
}
var ellipsestext = "";
var moretext = "+";
var lesstext = "-";
$('.more', nRow).each(function() {
var content = $(this).html();
if(content.indexOf(",") != -1) {
var html = '' + content.split(",",1) + ''+'' + content + ' ' + moretext + '';
$(this).html(html);
}
});
return nRow;
}
});
[/code]
The formatting is working fine. Now when I try to call click on elements with class "morelink" (which is an anchor) like below, the call is not occuring, instead the page is reloaded.
[code]
$(document).ready(function() {
$(".morelink").click(function(){
alert("click has worked!!");
});
});
[/code]
Can anyone please let me know why I'm not able to make the click call above ?
Thanks
aj
I'm a beginner using datatables for my application. I'm trying to format data in a table to expand and contract content which is having comma seperated values. I'm trying to do the formatting using "fnRowCallback" like below:
[code]
oTable = $('#searchResultsTable').dataTable( {
"bStateSave" : true,
"sPaginationType" : "full_numbers",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(0)', nRow).html( 'View');
if(aData[5].indexOf(",") != -1) {
$('td:eq(5)', nRow).html( ''+aData[5]+'');
}
var ellipsestext = "";
var moretext = "+";
var lesstext = "-";
$('.more', nRow).each(function() {
var content = $(this).html();
if(content.indexOf(",") != -1) {
var html = '' + content.split(",",1) + ''+'' + content + ' ' + moretext + '';
$(this).html(html);
}
});
return nRow;
}
});
[/code]
The formatting is working fine. Now when I try to call click on elements with class "morelink" (which is an anchor) like below, the call is not occuring, instead the page is reloaded.
[code]
$(document).ready(function() {
$(".morelink").click(function(){
alert("click has worked!!");
});
});
[/code]
Can anyone please let me know why I'm not able to make the click call above ?
Thanks
aj
This discussion has been closed.
Replies
Allan