首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在jquery对话框中显示html格式的文本对话框按钮单击

在jquery对话框中显示html格式的文本对话框按钮单击
EN

Stack Overflow用户
提问于 2018-07-14 05:11:43
回答 0查看 1.1K关注 0票数 0

我有一个在发现字段验证错误时打开的对话框。我已经成功地在jQuery对话框中捕获了html格式的文本。我在对话框中定义了3个按钮。继续(关闭对话框)、显示字段(应显示字段错误html文本)和显示详细信息(应显示错误详细信息)

下面是来自该页面的HTML代码

代码语言:javascript
运行
复制
<div id="dialogpresubval" title="Pre-Submit Validation Errors" style="display:none">
    <div id="fielderrors" style="display:none"> &nbsp; </div>
    <div id="errordetail" style="display:none"> &nbsp; </div>
</div>

这是Ready函数中.js文件中的代码,当我按下主窗体上的Submit按钮时,我会得到presubfield和presubdetail变量。我知道这个部分正在工作,因为console.log行显示了正确的信息。出于测试目的,您可以在此处使用

代码语言:javascript
运行
复制
var presubfields = "The following fields contain errors: <br> member status <br> member since";

$(function() {
    $( "#dialogpresubval").dialog({
        autoOpen: false, 
        hide: "puff",
        modal: true,
        closeOnEscape: false,
        height:400,
        width:450,
        resizable: true,
        draggable: true,
        title: "Pre-Submit Validation Errors",
        open: function() {
            console.log("4119 - On Open presubfields is: " + presubfields);  // I see the presubfields variable and its text;
            // $("#fielderrors div").html(presubfields);
            // $("#fielderrors", {html:presubfields});
           },          
           buttons: [ 
            {
               text: "Continue",
               click: function() {
                   var button = $(this).prop("id"); 
                   console.log("4127 You clicked on:", button);
                   $(this).dialog("close");
               },
            },
            {
                text: "Show Fields",
                click: function() {
                   var button = $(this).prop("id"); 
                   // Show the Fields requiring correction - div id = fielderrors
                    //var field_errors = $('#dialogpresubval').attr('note_text');
                console.log("4143 - presubfields = " + presubfields);  // console shows the correct information;
                //$("#fielderrors").append(presubfields);
                //$("#fielderrors", {html:presubfields});
                $("#fielderrors").text("presubfields should be shown");
                // Used this to test for generic text - $("#fielderrors").text("presubfields should be shown");
                // $("#fielderrors").val(presubfields);
                //$("#fielderrors").prop('display', 'block');
                $("#fielderrors").css({'display':'block'});
                $("#errordetail").hide();
                },

            },
            {
                text: "Show Details",
                click: function() {
                // Show the Details of the errors - div  id = errordetail
                // presubfields presubdetail
                $("#errordetail").val(presubdetail);
                $("#errordetail").show();
                $("#fielderrors").hide();
                },
            }
           ],
           position: {
              my: "center center",
              at: "center center"
           }

        });
    });

我留在注释掉的字段中,这样您就可以看到我已经尝试过的内容。我无法让presubfield或presubdetail显示在相应的div中。

我想要的是,当按下Show Fields按钮时,会显示presubfield html,presubdetail也是如此。

谢谢你的关注。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51332860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档