semantic-ui modal Close - OK/Cancel Callback

Guddu picture Guddu · Mar 5, 2015 · Viewed 16.7k times · Source

Is it possible to specify callback functions for Ok and Close button?

In case of JQuery Modal one could specify the callback functions at the time of initialization using the buttons dictionary. Does Semantic-ui modeal provide for something similar? How do i go for additional logic and close the model after Ok is pressed?

Answer

kite_n_code picture kite_n_code · Mar 7, 2015

add a .approve class (or alternative. see http://semantic-ui.com/modules/modal.html#/settings to your 'OK' button to trigger the onApprove callback.

.close class for your Close button.

I have only be using semantic-ui for 2 weeks (and modals for a few hours) so caution required. Thanks mike123 for your answer.

$('.ui.modal.myModal').modal({
        onHide: function(){
            console.log('hidden');

        },
        onShow: function(){
            console.log('shown');
        },
        onApprove: function() {
            console.log('Approve');
            return validateModal()
        }
    }).modal('show');