Prevent row selecting on link click

Prevent row selecting on link click

gasgas Posts: 6Questions: 0Answers: 0
edited December 2012 in General
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?

Replies

  • gasgas Posts: 6Questions: 0Answers: 0
    edited December 2012
    The example solution i dont like

    [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]
  • gasgas Posts: 6Questions: 0Answers: 0
    Nevermind found this

    [code]
    "fnPreRowSelect": function ( e, nodes ) {
    if ( $(e.currentTarget).hasClass('editable') ) {
    return false;
    }
    return true;
    }
    [/code]
This discussion has been closed.