Prevent Deselect when selecting the same cell twice

Prevent Deselect when selecting the same cell twice

apersonaperson Posts: 1Questions: 0Answers: 0

I have a pretty simple table setup and am adding hooks to select and deselect events. Unfortunately my behavior relies on the user selecting a cell and then clicking an element within that cell. However, this just deselects the cell which is not what I want. How can I prevent the deselect event from firing? I attempted to prevent the deselect but it looks like the class that is added on select is removed prior to the deselect event firing.

How can I prevent deselect from firing?

Replies

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    on the inner element, have you tried .stopPropagation() on the event object?

    Below is a way to prevent a selected cell from being deselected.

    table
        .on( 'user-select', function ( e, dt, type, cell, originalEvent ) {

       if( $(cell.node()).hasClass("selected")) {
           e.stopPropagation();
           return false;
       }
    

       
        } );

This discussion has been closed.