jQuery对话框作为输入

3

我不太熟悉使用jquery的对话框等工具。

因此这是一个初学者问题。

目前,我在我的SharePoint中使用提示框(prompt)来获取用户的回复。

var answer = dialog("Type the text you want to display in the email.");

但是我的输入受到限制。

有人能帮助我吗?

补充。 现在我可以插入我的对话框了。但我无法显示它。

这是我如何插入它的:

if ($("#dialogSendMail").length) {

}
else {
    $("#DeltaPlaceHolderUtilityContent").after("<div id='dialogSendMail' title='Enter mail body'> <label for='mailBody'>Type the text you want to display in the email:</label><p><input type='text' id='mailBody' name='mailBody'></p></div>");
}

这是我尝试展示它的方式:

        var answer ="";

    $( "#dialogSendMail" ).dialog({
            resizable: false,
            height:350,
            width:650,
            modal: true,
            autoOpen : false,
            buttons: [
                {
                    text: "Send Mail",
                    click: $.noop,
                    type: "submit",
                    form: "myForm"
                },
                {
                    text: "Close",
                    click: function () {
                        $(this).dialog("close");
                    }
                }
            ]
        });

但是当我运行我的代码时,它没有显示对话框。此外,我正在尝试找到一种获取文本框响应的方法。请问是否有人可以帮助我?

Dejan.S:展示我的答案不是问题。这我能做到。 - Bart Schelkens
1个回答

2

纯jQuery没有这样的对话框,请使用jQuery UI。您真正的问题是什么?

$( "form" ).dialog({
    open: function() {
        // On open, hide the original submit button
        $( this ).find( "[type=submit]" ).hide();
    },
    buttons: [
        {
            text: "Find",
            click: $.noop,
            type: "submit",
            form: "myForm" 
        },
        {
            text: "Close",
            click: function() {
                $( this ).dialog( "close" );
            }
        }
    ]
});

fiddle: http://jsfiddle.net/s9ff3gjs/1/


1
你的代码看起来不错,但是在你的代码中,JS和HTML混在了一起,我认为这样做不太好。这是更好的方式: http://jsfiddle.net/ent1c3d/s9ff3gjs/2/ - EntGriff

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接