Jquery对话框提交验证

时间:2012-06-26 06:27:04

标签: asp.net html jquery-ui

我需要有人告诉我如何在提交之前使用jquery对话框询问“确认”或“取消”验证。我得到 Microsoft JScript运行时错误:对象在IE9上不支持属性或方法'对话'

<script type="text/javascript">
  $(document).ready(function () {

    $("#savechanges").click(function () {

        $("#dialog").dialog({
            modal: true,
            autoOpen: false,
            buttons: {
                "Confirm": function () {
                    $("#myformid").submit();
                },
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });         
        return false;
    });
});
</script>


<div id="dialog"></div>


 <p>
    <input type="submit" id="savechanges" value="Save changes" />
</p>

2 个答案:

答案 0 :(得分:0)

如果将autoOpen设置为false,则在定义对话框时不会打开。所以你应该设置它true

来自jQuery-UI文档,

autoOpen

When autoOpen is true the dialog will open automatically when dialog is called. 
If false it will stay hidden until .dialog("open") is called on it.

DEMO

答案 1 :(得分:0)

这个问题背后可能有多种原因,可以使用像firebug这样的调试工具来检查

  1. 使用Firebug for Firefox等工具验证是否包含了每个JS文件。
  2. 确保页面上没有可能导致错误的其他JS。

  3. 确认您已下载文件的正确版本。

相关问题