Closing Bootstrap Modal triggers Table Deselect event?
Closing Bootstrap Modal triggers Table Deselect event?
In my scenario I have a checkbox for each row that I manage through the select and deselect events.
* When there are selected rows and I open and close a bootstrap modal dialog, this appears to trigger the Table's deselect event.
* I don't understand what about closing the modal dialog is bringing the deselect along for the ride.
* I feel like I must be missing something obvious, but I can't see it.
Link to test case: https://jsfiddle.net/FrankLoWa/6m3utc08/53/
Debugger code (debug.datatables.net): enehex
Error messages shown: none
Description of problem: After selecting several rows - click "approve" button - modal dialog opens, close modal dialog.
Observe that all selected items are cleared, and in the console that the table's "deselect" event has been called.
The later was unexpected.
In my actual code I am using responsive, fixed headers, keys, and no paging among other features. In that code I use the option selector: 'input.select-row-checkbox' to limit the select to either this or pressing the enter key in other cells. But I've stripped as much of that away as possible to still demonstrate the behavior.
This question has an accepted answers - jump to answer
Answers
It is the
select.blurable
option being set to true. When that is enabled, Select will look for a click outside of the table. If it finds it, it blurs the row selection. That is exactly what is happening when you click in the model.This is the code in Select that handles that. We might need to put in a cancellable event so you can stop that from happening (we can't just put a check for a click inside a Bootstrap modal, since you might want to blur the row selection inside the modal!).
At the moment, the workaround would be to disable
select.blurable
.Allan
Thank you so much for the help. As you say, setting blurable to false resolved the unexpected behavior, and false is the correct value for my scenario, so not even a workaround.
That's me not understanding what this option meant (moving too fast, not reading... sigh)
I had it in my head in the category of
keys.blurable
where it was controlling whether the table retained focus... when the dialog had closed.