我有一个在发现字段验证错误时打开的对话框。我已经成功地在jQuery对话框中捕获了html格式的文本。我在对话框中定义了3个按钮。继续(关闭对话框)、显示字段(应显示字段错误html文本)和显示详细信息(应显示错误详细信息)
下面是来自该页面的HTML代码
<div id="dialogpresubval" title="Pre-Submit Validation Errors" style="display:none">
<div id="fielderrors" style="display:none"> </div>
<div id="errordetail" style="display:none"> </div>
</div>
这是Ready函数中.js文件中的代码,当我按下主窗体上的Submit按钮时,我会得到presubfield和presubdetail变量。我知道这个部分正在工作,因为console.log行显示了正确的信息。出于测试目的,您可以在此处使用
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也是如此。
谢谢你的关注。
https://stackoverflow.com/questions/51332860
复制相似问题