Buttons how to delete a container instance.

Buttons how to delete a container instance.

kinetikkinetik Posts: 10Questions: 4Answers: 0

Hello Community. I am dynamically creating button instances. to load into a dialog box to allow for manipulation of some features. I am to create the instances and append it to the element as I wish. Im also able to delete the buttons that reside inside the container but I'm unable to delete the container itself.

           new $.fn.dataTable.Buttons( dt, {
                buttons: [
                    {
                        text: 'Button 2',
                        className: 'lateralPanel',
                        action: function ( e, dt, node, conf ) {
                            dt.buttons(dt.buttons().containers().length-1, null ).destroy();
                            myLateral.lateral('close');
                        }
                    }

                ]
            } );

            dt.buttons(dt.buttons().containers().length-1,null).container().appendTo('#testlat');  

This remove the buttons from the container but the newly created container is still there just empty with no buttons.

So the question is how to I empty .containers() of my newly created instance. So i don't continue to fill it with empty instances of buttons.

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    so after the destroy, remove the container html using jquery

  • kinetikkinetik Posts: 10Questions: 4Answers: 0
    oTable.buttons().container()
    (5) [div.dt-buttons, div.dt-buttons, div.dt-buttons, div.dt-buttons, div.dt-buttons, prevObject: 
    oTable.buttons().container()[4]
    <div class=​"dt-buttons">​ ​</div>​
    oTable.buttons().container()[4].remove()
    undefined
    oTable.buttons().container()[4]
    <div class=​"dt-buttons">​ ​</div>​
    oTable.buttons().container()[4].splice
    undefined
    oTable.buttons().container()[4]
    <div class=​"dt-buttons">​ ​</div>​
    

    Example. I have 5 Containers in this example. Id like to remove the 5th instance from this object. using splice and remove does not remove it from the referenced object. but does remove any buttons in it.

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    http://jsbin.com/miladah/edit?html,css,js,output removes each button when it is clicked then removes the container if there are no buttons left. Is this what you are trying to do?

This discussion has been closed.