- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚写了一些代码,遇到了这样的问题:
alertify.dialog("confirm").set(
{
'labels':
{
ok: 'Personal',
cancel: 'Share'
},
'message': 'Select target:',
'onok': function()
{
alertify.confirm($("#dir_select_user").get(0), function()
{
var i = $("#dir_select_user .dir_selector").val();
t.find(".move_des").val(i);
t.find(".move_verify").val("1");
t.submit();
}).set('labels',
{
ok: alertify.defaults.glossary.ok,
cancel: alertify.defaults.glossary.cancel
});
},
'oncancel': function()
{
alertify.confirm($("#dir_select_share").get(0), function()
{
var i = $("#dir_select_share .dir_selector").val();
t.find(".move_des").val(i);
t.find(".move_verify").val("1");
t.submit();
}).set('labels',
{
ok: alertify.defaults.glossary.ok,
cancel: alertify.defaults.glossary.cancel
});
}
}) }).show();
我使用来自 http://alertifyjs.com 的 alertifyjs
库(不是来自 http://fabien-d.github.io/alertify.js/ )。
如果您尝试这段代码,您会发现在选择personal
或share
后,“onok”和“oncancel”对话框很快消失。
这里有什么问题?我该如何解决?
最佳答案
问题的根源是您试图在关闭时再次显示相同的对话框。默认的 AlertifyJS 对话框都是单例的(始终是一个实例)。
你有 2 个解决方案:
延迟显示第二个确认,直到第一个确认实际关闭。
alertify.confirm("confirm ? ",
function onOk() {
//delay showing the confirm again
//till the first confirm is actually closed.
setTimeout(function () {
alertify.confirm("confirm another time ?");
}, 100);
},
function onCancel() {
//no delay, this will fail to show!
alertify.confirm("this will not be shown!");
}
);
创建您自己的 transient (多实例)确认,只需继承现有的即可。
// transient (multi-instance)
alertify.dialog('myConfirm', function factory(){ return {};},true,'confirm');
alertify.myConfirm("confirm ? ", function(){
alertify.myConfirm("confirm another time ?");
});
注意:对此要小心,因为每次调用 transient 对话框都会创建一个新实例,您可以保存对已启动实例的引用并重新使用它们!
查看演示 here .
关于javascript - Alertify 对话框在确认前消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28278829/
我正在使用 alertify.error 来显示错误消息。我想知道是否有任何方法可以更改显示在里面的文本的字体颜色? 最佳答案 好吧,正如我所见,它使用这段代码来更改字体颜色和整体字体样式: .ale
我正在为我的对话框使用 Alertify Jquery 插件。问题是,一次确认后一次确认似乎不起作用: // confirm dialog function go(){ alertify.co
我决定使用 Alertify 来修改和设计我的代码。我的旧代码: $('.ask').click(function(){ var answer = confirm('translate('D
我是alertify.js的新手。我想做的是,当用户点击链接时,浏览器应该显示确认框。如果用户单击 则转到下一页。如果用户单击“取消”,则留在同一页面上。是否可以使用alertify.js来做到这一点
我刚刚写了一些代码,遇到了这样的问题: alertify.dialog("confirm").set( { 'labels': { ok: 'Personal',
我有一个按钮,单击该按钮后,我将在 Bootstrap 模型中显示一个表单。我想要实现的是在表单提交时显示确认框。一切正常,但确认信息出现在引导模型的后台。 HTML Notify Cust
我有这样的 HTML 行 (new) save -
所以我有这些代码行: $('td').click(function (e) { var test = "...."; var test2 = "...."; var test3
我正在尝试使用 alertify.js 作为我所有确认脚本的确认对话框。但它不像常规 JS confirm 那样工作。在下面的代码中,我从未得到 return true function aConf
我的页面中有一个表单可以自行提交。在 PHP 部分我检查 if($_SERVER['REQUEST_METHOD'] == 'POST') 然后我运行一些东西。我正在尝试使用 Alertify 显示警
您好,我正在尝试将alertify.js 作为警报弹出窗口包含在我的网页上,但我不确定为什么它没有显示。我已经下载了alertify 的库和源代码,但我不确定我是否正确使用它。任何建议都会有很大帮助。
使用alertify - 版本0.3.11,我能够获取用户输入详细信息并能够在提示对话框中显示它。但我有多种值(value)观。用户输入、下拉值、日期选择等 var totalResources =
$("#btn_submit").click(function(){ alertify.prompt("Please enter note/remarks for this Form:", f
我正在使用 Alertify 库在我的 javascript 中创建一个对话框, alertify.myAlert || alertify.dialog('myAlert',function fact
我在使用 alertify JS confirm 时遇到了问题。当我单击该按钮时,不会出现 alertify 确认,但会立即重定向到该链接。以下脚本链接按钮和 alertify 确认脚本。 funct
有没有办法让 Alertify Js 插件的对话窗口居中? http://alertifyjs.com 我看到有个属性叫position,但是不支持center position。 谢谢大家 最佳答案
我正在尝试将以下老派代码片段转换为 alertify.js 0.3.8: window.doPrompt = function() { var str; do str = prompt("En
我正在使用 Alertify JQuery 插件,用于显示 alert,confirm, dialog 框。 确认时遇到问题,单击“确定”或“取消”时无法正常工作 Sample JS FIDDLE J
我正在尝试使用alertifyjs(https://alertifyjs.org/)库。 在代码预览网站(例如codepen)中或在stackoverflow上测试警报时,警报将按预期方式工作。 但是
我正在开始使用 jquery 插件,并且决定尝试一下 Alertify。我访问了网页: http://fabien-d.github.io/alertify.js/ 它告诉我使用 Bower 包管理进
我是一名优秀的程序员,十分优秀!