Jquery 设置对话框显示的值

Jquery 设置对话框显示的值,jquery,modal-dialog,Jquery,Modal Dialog,我有密码: $(function() { $("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 300, modal: true, buttons: { Cancel: function() { $(this).dial

我有密码:

$(function() {
        $("#dialog").dialog({
            bgiframe: true,
            autoOpen: false,
            height: 300,
            modal: true,
            buttons: {
                Cancel: function() {
                    $(this).dialog('close');
                }
            },
            close: function() {
                allFields.val('').removeClass('ui-state-error');
            }
        });

        $("input[name=edit]").click(function() {
            alert(1);
            $("#dialog input[@id=ItemId]").val($("ItemId"));
            alert(2);
            $("#dialog input[@id=CatId]").val($("CatId"));
            $("#dialog input[@id=UnitId]").val($("UnitId"));
            $("#dialog input[@id=SaleOffId]").val($("SaleOffId"));
            $("#dialog input[@id=ItemCode]").val($("ItemCode"));
            $("#dialog input[@id=ItemName]").val($("ItemName"));
            $("#dialog input[@id=UnitCost]").val($("UnitCost"));

            $('#dialog').dialog('open');
        })
    .hover(
        function() {
            $(this).addClass("ui-state-hover");
        },
        function() {
            $(this).removeClass("ui-state-hover");
        }
    ).mousedown(function() {
        $(this).addClass("ui-state-active");
    })
    .mouseup(function() {
        $(this).removeClass("ui-state-active");
    });
    });
我想设置对话框的值,它是表单支持的。我编写了函数$(“input[name=edit]”)。单击(函数()可设置对话框的值。每个按钮都是单击编辑的,但它是错误的。我不知道我哪里出错了。请帮助我


如果您正在使用jQuery 1.3,请首先从属性选择器中删除
@
符号,谢谢

$("#dialog input[@id=CatId]")
应该成为

$("#dialog input[id=CatId]")
来自jQuery文档的报价:

注意:在jQuery 1.3中,删除了[@attr]样式选择器(它们以前在jQuery 1.2中被弃用)。只需从选择器中删除“@”符号,即可使其重新工作

更好的改进是改变

$("#dialog input[id=CatId]")

因为ID必须是唯一的

$("#CatId")