Buy now!

NinjaModal

Sample 04. Using onLoad and onClose events

Events Sample

HTML

                        

Events Sample

JS

                        function showModal() {
                            ninjaModal({
                                css: "nc-modal-small",
                                title: 'Events Modal',
                                width: 400,
                                html: 'On load it set the focus. On close, display confirmation ',
                                onLoad: function () {
                                    $("#modalInput").focus();
                                },
                                onClose: function () {
                                    //-- new confirmation modal
                                    ninjaModal({
                                        title: 'Confirmation Modal',
                                        html: 'Do you really want to close it?',
                                        buttons: [
                                            {
                                                text: 'Yes',
                                                callback: function (modal) {
                                                    modal.close();
                                                    firstModal.close();
                                                }.bind(firstModal)
                                            },
                                            {
                                                text: 'No'
                                                //-- do nothing
                                            }
                                        ]
                                    });
                                }
                            });
                            return false;
                        }
                    

On load it set the focus. On close, display confirmation