Вы были близки с $("#fielderrors div").html(presubfields);
, но это говорит, что найти элемент div, который находится внутри другого элемента с идентификатором fielderrors
. В вашем HTML нет такого элемента.
Вместо этого вы можете просто использовать только идентификатор (ID-элементы должны быть уникальными), поэтому в открывшейся функции будет $("#fielderrors").html(presubfields);
.
Теперь у вас есть html div, поэтому следующий шаг - либо .show () и / или .hide () элементы при нажатии соответствующих кнопок. Пример ниже.
var presubfields = "The following fields contain errors: <br> member status <br> member since";
var presubdetail = "I am an example of an error detail.";
$(function() {
$("#dialogpresubval").dialog({
autoOpen: false,
hide: "puff",
modal: true,
closeOnEscape: false,
resizable: true,
draggable: true,
title: "Pre-Submit Validation Errors",
open: function() {
$("#fielderrors").html(presubfields)
$("#errordetail").html(presubdetail);
},
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() {
$("#fielderrors").show();
$("#errordetail").show();
},
},
{
text: "Show Details",
click: function() {
$("#fielderrors").hide();
$("#errordetail").show();
},
}
],
position: {
my: "center center",
at: "center center"
}
});
// show the modal
$( "#dialogpresubval" ).dialog( "open" );
});
<link href="https://code.jquery.com/ui/1.11.4/themes/black-tie/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<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>