Prevent row selecting on link click
Prevent row selecting on link click
Hello. I have TableTools extension with "sRowSelect": "multi" property and i have some issues. The major problem is: i have a cell with checkbox for row selection and i have cell with links. When i click on link the row gets selected which i dont want. I want row become selected when i click on checkbox (this part is easy).
I tried to implement custom selection through API with fnSelectRow function but this function does not work if i set "sRowSelect" to null. I tried to implement custom link click function but the selection function called before it so i cant prevent selection from within .click function like:
[code]
$('.link').live('click', function(e) {
e.preventDefault();
return false;
});
[/code]
So i have an option to delegate click on TD element then extract target attribute and manually call click function but i dont like this solution. Is there any other option?
I tried to implement custom selection through API with fnSelectRow function but this function does not work if i set "sRowSelect" to null. I tried to implement custom link click function but the selection function called before it so i cant prevent selection from within .click function like:
[code]
$('.link').live('click', function(e) {
e.preventDefault();
return false;
});
[/code]
So i have an option to delegate click on TD element then extract target attribute and manually call click function but i dont like this solution. Is there any other option?
This discussion has been closed.
Replies
[code]
$("#example tbody").delegate("td", "click", function(e) {
var target = e.target;
if($(target).hasClass('link1class'))
{
do something 1;
return false;
}
else if ($(target).hasClass('link2class'))
{
do something 2;
return false;
}
else if ($(target).hasClass('link3class'))
{
do something 3;
return false;
}
});
[/code]
[code]
"fnPreRowSelect": function ( e, nodes ) {
if ( $(e.currentTarget).hasClass('editable') ) {
return false;
}
return true;
}
[/code]