配置jquery ui对话框以替换javascript确认

时间:2013-08-12 12:04:57

标签: jquery-ui-dialog

$back = mysql_query("SELECT * FROM student WHERE roll_no=".$_POST['roll']) or die(mysql_error());
$backup = mysql_fetch_array($back) or die(mysql_error());
<form method='post'>
    <input type='submit' name='undo' value='Undo' 
        onsubmit="return confirm('Are you sure you want to rollback deletion of 
            <?php echo $backup['name'];?> 
            from 
            <?php echo $backup['post'];?>
            ?')"/>
</form>

如何使用上述参数替换javascript与jquery ui对话框确认。

1 个答案:

答案 0 :(得分:0)

<form id="submitform" method='post'> ... </form>

   $('<div></div>').appendTo('body')
                        .html("<div><span>Submit form " + document.getElementById('phpcode').innerHTML+"</span></div>")
                        .dialog({
                            modal: true, title: 'Submit form', zIndex: 100, autoOpen: true,
                            width: 'auto', resizable: false,
                            buttons: {
                                Yes: function () {
                                    $("#submitform").submit();
                                    $(this).dialog("close");
                                },
                                No: function () {
                                    $(this).dialog("close");
                                }
                            },
                            close: function (event, ui) {
                                $(this).remove();
                            }
                        });


<div id="phpcode"><?php echo $backup['name'];?> 
            from 
            <?php echo $backup['post'];?>
            ?')"/>
</div>

这应该与简单的javascript确认对话相同。