单击菜单项时无法打开我的jQuery对话框 [英] Can't get my jQuery dialog to open on menu item click

查看:79
本文介绍了单击菜单项时无法打开我的jQuery对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有了第一个使用jQuery的应用程序,并且已经建立并执行了两个对话框,并且在单击登录"(在文件"菜单中)时出现了登录框,但是单击打开"时,无法显示打开"框.

I've got my first app with jQuery coming along, and I've got both my dialog boxes built and executing as they should be, and the login box comes up when I click login (in the File menu), but I can't get the Open box to come up when I click Open.

这是我的两个对话框的jQuery代码:

Here's my jQuery code for both dialogs:

$("#login-form").dialog({
    autoOpen: false,
    height: 350,
    width: 350,
    modal: true,
    buttons: {
        "Log In": function () {
            var bValid = true;
            allFields.removeClass("ui-state-error");

            bValid = bValid && checkLength(username, "username", 3, 16);
            bValid = bValid && checkLength(password, "password", 5, 16);

            bValid = bValid && checkRegexp(username, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter.");
            bValid = bValid && checkRegexp(password, /^([0-9a-zA-Z])+$/, "Password may consist of : a-z 0-9");

            if (bValid) {
                if (username.val() == "admin" && password.val() == "password") {
                    $("#users tbody").append("<tr>" + "<td>" + username.val() + "</td>" + "<td>" + password.val() + "</td>" + "</tr>");
                    $(this).dialog("close");
                } else {
                    alert("Invalid Username/Password Combo");
                }
            }
        },
        Cancel: function () {
            $(this).dialog("close");
        }
    },
    close: function () {
        allFields.val("").removeClass("ui-state-error");
    }
});

$("#dateturn-form").dialog({
    autoOpen: false,
    height: 550,
    width: 350,
    modal: true,
    buttons: {
        "Accept": function () {
            $("#content-left").append("<p>Date: " + dateinput.val() + " turn: " + turnvalue + "</p>");
            $(this).dialog("close");


        },
        Cancel: function () {
            $(this).dialog("close");
        }
    }
});

$("#login")
    .click(function () {
    $("#login-form").dialog("open");
});

$("#open")
    .click(function () {
    $("dateturn-form").dialog("open");
});

这是该项目的jsFiddle链接: http://jsfiddle.net/CHBrn/1/由于某种原因,就像我上面说的那样,单击打开"按钮将无法启动该项目.

And here's a jsFiddle link to the project: http://jsfiddle.net/CHBrn/1/ For some reason, like I said above, clicking the Open button won't launch the project.

推荐答案

再次Alex :)您在ID选择器中缺少#

Once again Alex :) You are missing # in ID selector

演示

$("#dateturn-form").dialog({ });

这篇关于单击菜单项时无法打开我的jQuery对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆