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'

aj_85aj_85 Posts: 3Questions: 0Answers: 0
edited January 2012 in General
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

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    http://datatables.net/faqs#events :-)

    Allan
  • aj_85aj_85 Posts: 3Questions: 0Answers: 0
    Thanks a lot. I used live event. :-) *Happy Dance*
This discussion has been closed.