When adding a button to a secondary split menu, how do you drop the menu on action?

When adding a button to a secondary split menu, how do you drop the menu on action?

desperadodesperado Posts: 159Questions: 33Answers: 4

This is issue #2 I am having with the StateRestore split menu.
How do you drop the menu when your action is called?

Test Case http://live.datatables.net/nebunuco/2/edit?js,output
1) Create a Saved State
2) Open the Saved States menu then open the secondary menu and select "test"
3) The function correctly writes to the console as expected but I don't now how to lower the secondary menu in my function.
(See Question #1 in the example.)

This question has an accepted answers - jump to answer

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @desperado ,

    You would need to use the button().trigger() api method, selecting the button that you want to trigger. Take a look at this updated version of your example.

    Thanks,
    Sandy

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @sandy But I don't want to return to the states menu, I want to close the menu's and return the page. If I trigger a button it will trigger the action. Your example demonstrates this because the State's list menu displays.

    So I want to just close the window. I found this solution but it seems like a hack. Should I just use this solution or is there a "right" way to just close the button collection. I wonder how "Save", "Rename" and "Remove" buttons are closing? I assumed autoclose was set to true but since buttons I add do not close I suspect it is set to false.

    https://datatables.net/forums/discussion/30683/how-to-close-the-buttons-collection-button-menu

    They used
    $(".dt-button-background").trigger("click");

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi @desperado ,

    Sorry I misunderstood...

    how to lower the secondary menu in my function.

    ...as showing the dropdown menu.

    Yes, clicking the background is valid, alternatively you can enable autoClose for the stateRestore collection - see this example.

    Thanks,
    Sandy

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @sandy I would have sworn I tried setting autoClose true on the collection and it didn't work, not sure what I did wrong. Thanks for the answers!

Sign In or Register to comment.