gpt4 book ai didi

jsf - Primefaces 多个对话框与 closeOnEscape

转载 作者:行者123 更新时间:2023-12-04 01:09:28 27 4
gpt4 key购买 nike

我有 2 个对话(A 和 B)与 closeOnEscape="true" .

两个对话框都是模态的并且有<p:focus context="innerForm" />里面。

对话框 A 打开对话框 B。是的,我知道,这是一个糟糕的设计,但是......

问题是,当我在对话框 B 上按 ESC 时,它会正确关闭并将焦点返回到对话框 A,但 ESC 不会关闭此对话框。

最佳答案

这是一个错误,已报告给 GitHub 上的 PrimeFaces: https://github.com/primefaces/primefaces/issues/6677

公关:https://github.com/primefaces/primefaces/pull/6678

将在 PF 9.0 中

将此添加到 PF 后加载的 JS 中以立即修复它:

if (PrimeFaces.widget.Dialog) {
PrimeFaces.widget.Dialog.prototype.bindEvents = function() {
var $this = this;

//Move dialog to top if target is not a trigger for a PrimeFaces overlay
this.jq.on("mousedown", function(e) {
if (!$(e.target).data('primefaces-overlay-target')) {
$this.moveToTop();
}
});

this.icons.on('mouseover', function() {
$(this).addClass('ui-state-hover');
}).on('mouseout', function() {
$(this).removeClass('ui-state-hover');
}).on('focus', function() {
$(this).addClass('ui-state-focus');
}).on('blur', function() {
$(this).removeClass('ui-state-focus');
});

this.closeIcon.on('click', function(e) {
$this.hide();
e.preventDefault();
});

this.maximizeIcon.on("click", function(e) {
$this.toggleMaximize();
e.preventDefault();
});

this.minimizeIcon.on("click", function(e) {
$this.toggleMinimize();
e.preventDefault();
});

if (this.cfg.closeOnEscape) {
$(document).on('keydown.dialog_' + this.id, function(e) {
var keyCode = $.ui.keyCode;
if (e.which === keyCode.ESCAPE && $this.isVisible()) {
var active = parseInt($this.jq.css('z-index')) === parseInt($('.ui-dialog:visible').last().css('z-index'));
if (active) {
$this.hide();
}
};
});
}
};
}

关于jsf - Primefaces 多个对话框与 closeOnEscape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65329834/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com