Remove collection when there are no more buttons present in the collection
Remove collection when there are no more buttons present in the collection

Link to test case:
Problem/Question:
Remove all collection sub buttons, leave parent.
https://jsfiddle.net/m1Leztu6/16/
Issue/bug:
Remove all collection sub buttons including parent (layout issue)
https://jsfiddle.net/m1Leztu6/13/
Under this second test case with Bootstrap 4 styling, removing a button does not remove the parent btn-group div which impacts layout of the remaining buttons. I am dynamically removing the buttons based on attributes of the button.
Debugger code (debug.datatables.net): amoyuc
Error messages shown: None
Description of problem:
I would like to try to under the first test marked problem/question leave the parent button but then after removing the collections buttons check to see if there are any remaining buttons in the collection, and if not then remove the parent button. However I could not find any function to retrieve a collections parent, and the associated children buttons in the collection to do that, or any link to the parent button from the child button being removed. Is it possible to achieve what I am trying to do?
This question has an accepted answers - jump to answer
Answers
It feels a little on the hacky side, it is possible if you know the parent button's index. The idea is that you simply request the first sub button for that index - if it doesn't work, an error will be thrown, so you can do a try / catch:
Might be nicer if the API provided a way to handle this. I'll consider how that might be done.
Allan
Thanks Allan. And for the removal of button leaving an orphaned btn-group div, would you consider that a bug? Unfortunately it breaks the button layout.
Issue/bug:
Remove all collection sub buttons including parent (layout issue)
https://jsfiddle.net/m1Leztu6/13/
Sorry, yes, I missed that point. I totally agree, that's a bug. Fix committed here.
Allan