vendredi 8 mai 2015

Close modal without redirect

I have a modal that is created when I click a button. It's content is php - generated because I need to communicate with the server to do some action. Besides the submit button (which works fine btw) I have another button which should just close the modal without doing any action.

I know I can achieve this by encapsulating the button in

But I don't want to reload the page, so I'm trying to do it using jquery's close() function. However, the result achieved is that the window closes immediately. This is the code of the content:

        <body>
                <?php 
                        echo '<form action="action.php" method="post">';
                        echo '<p >Are you sure you want to do this?</p>';
                        echo '<input type="submit" value="YES"></input>';         
                        echo '</form>'; 
                ?>
                <input type="button" value="NO" id="reject">

                <script type="text/javascript">
                            $(document).ready( function() {         $('#reject').onclick($("#delete_dialog").dialog("close"))});
                </script>
    </body>

delete_dialog is the id of the modal

Aucun commentaire:

Enregistrer un commentaire