Cancel selection blur

Cancel selection blur

sliekenssliekens Posts: 97Questions: 17Answers: 2
edited November 2016 in Free community support

When using the Select plugin with option { blurable: true }, clicking any element outside the table causes rows to be deselected.

How can I disable blurable for specific elements outside the table?

I'm asking because I intend to use my own buttons instead of the Buttons plugin. When my custom button is clicked, all selected rows are deselected.

<button id="delete">Delete</button>
<table id="example">...</table>
var table = $('#example').DataTable( {
    select: {
        blurable: true
    }
} );

$('#delete').on('click', function() { table.rows('.selected').remove(); });

This code works in the sense that the button handler is executed before rows are deselected, but the user experience sucks because the selection is cleared immediately after that.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Answer ✓

    How can I disable blurable for specific elements outside the table?

    You'd need to modify the Select code. This is where it makes that decision.

    It might be worth updating to the nightly. If your buttons are in the table container then the rows won't be deselected.

    Allan

  • sliekenssliekens Posts: 97Questions: 17Answers: 2
    edited November 2016

    My buttons are not in the table container. :/

    I see that the code makes an exception for Editor forms when deciding whether to blur. I think I'll just wrap my buttons in a <div> with class DTE and hope that you never change that behavior.

This discussion has been closed.