Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置JQuery对话框的默认行为_Jquery_Jquery Ui - Fatal编程技术网

设置JQuery对话框的默认行为

设置JQuery对话框的默认行为,jquery,jquery-ui,Jquery,Jquery Ui,我正在使用jquery的对话框api。像这样: <tr> <td>&nbsp;</td> <td colspan="3"> <a href='#' id='btnAddNewSkill'> add new</a> </td> <td> <div id="addNewSkillDialog" style='visibi

我正在使用jquery的对话框api。像这样:

<tr>
    <td>&nbsp;</td>
    <td colspan="3">
            <a href='#' id='btnAddNewSkill'> add new</a>
    </td>
    <td>
        <div id="addNewSkillDialog" style='visibility: hidden;'>

        <form>
            <table width='100%' border='0'>
                <tr>
                    <td>
                        <label for="name">Name of New Skill</label> 
                        <input type="text" name="name" id="name" class=" ui-corner-all" />
                    </td>
                </tr>
            </table>
        </form>
        </div>
    </td></tr>
这不是执行此操作的正确步骤。。。。。
我应该如何从开始表单制作为对话框供参考,这不是一个确切的例子,因为时间紧迫(该离开了),但我今天早些时候回答了一个关于ui对话框的问题

看我的*修好了吗

如果我以后有机会,(如果没有其他人得到)我会让你胡乱模仿你的例子。但是,如果您查看提供的链接,您将看到如何建立一个对话框,并且您将看到html,因为它实际上是在html区域中编写的(也就是在主体中的视图中)

尽管jquery的默认值是
autoOpen:false
,但我使用了一点简单的css来确保它在加载时保持隐藏。这是因为,有时,如果您不将对话框CSS设置为显示:无,则在隐藏对话框之前会有一个轻微的闪烁

更新 下面,我将发布带有注释的代码,这是您的代码的格式副本,带有更正

<!-- CSS
onload (in other words, place in header or in header link -->
#addNewSkillDialog {
    display: none;
}

但我通过使用CSS的显示思想实现了它:无
<!-- CSS
onload (in other words, place in header or in header link -->
#addNewSkillDialog {
    display: none;
}
// you dont set the dialog in the click,
// set it seperately, use the click to open it
$("#addNewSkillDialog").dialog({
    //  HERE IS WHAT YOU'RE MISSING !!!
    autoOpen: false,
    //  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    show: "fold",   //  the animation on show
    hide: "explode",    // the animation on close
    resizable: false,   // prevents user from resizing
    modal: true,    //  puts a screen behind modal that prevents clicking on page
    closeOnEscape: true,    //  esc key will close dlg
    height: 120,    //  INNER height of dialog
    title: 'Add New Skill', // dlg title in ttl bar
    buttons: {  //  your own button set
        "Add Skill": function(e) {
            alert('Add skill Clicked');
        },
        Cancel: function(e) {
            $(this).dialog("close");
        }
    },
    close: function(e) {
        //$(this).dialog("dispose");    //  unnecessary
    }
});

//  then establish your click to open it
$('#btnAddNewSkill').click(function(e) {
    $("#addNewSkillDialog").dialog("open");
});