Cancel selection blur
Cancel selection blur
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
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
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.