gpt4 book ai didi

javascript - 如何在 Pnotify 中将焦点设置在按钮上

转载 作者:行者123 更新时间:2023-11-30 00:33:56 25 4
gpt4 key购买 nike

我在我的项目中使用 pnotify alert jquery。当对话框弹出时,我试图将焦点设置在确定按钮上。这样用户只需按回车键或空格键即可关闭对话框。但无法做到这一点。

This is link of pnotify
我的代码-

 function AlertAskOk(Heading, Message, type, okclick) {
var modal_overlay;

info_box = $.pnotify({
title: Heading,
text: Message,
type: type,
buttons: 'ok',
okclick: okclick,

icon: "picon picon-object-order-raise",
delay: 20000,
history: false,
stack: false,
// nonblock: true,

before_open: function (pnotify) {

// $("btn-inverse").focus();
// Position this notice in the center of the screen.
pnotify.css({
"top": ($(window).height() / 2) - (pnotify.height() / 2),
"left": ($(window).width() / 2) - (pnotify.width() / 2)
});

// Make a modal screen overlay.
modal_overlay = $("<div />", {
"class": "ui-widget-overlay",
"css": {
"display": "none",
"position": "fixed",
"top": "0",
"width": "5000px",
"bottom": "0",
"right": "0",
"left": "0",
"cursor": "pointer"

}
}).appendTo("body").fadeIn("fast");
},

//....

after_open: function (ui) {
$(".btn", ui.container).focus();
},
//....

before_close: function () {
modal_overlay.fadeOut("fast");
}
});

}

最佳答案

使用after_open 回调。检查这个demo .

new PNotify({
//....
after_open: function (notify) {
$(".btn-class", notify.container).focus();
}
//....
});

关于javascript - 如何在 Pnotify 中将焦点设置在按钮上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067554/

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