我正在尝试alertify.js用作所有确认脚本的确认对话框.但它只是不像普通的JS confirm那样工作.在下面的代码中我从来没有得到过return true
function aConf ( mes ) {
alertify.confirm( mes, function (e) {
return e;
});
}
<a href="#" onclick="if(aConf(\'Are you sure you wish to remove this?\')) { function(); } return false;">Delete</a>
Run Code Online (Sandbox Code Playgroud)
当然,如果我aConf用JS 替换' confirm它的工作原理.那么为什么alertify不把它送回去呢?
我想使用Alertify.js嵌入Qualtrics调查,但我不知道是否可以传入HTML代码段(可能是iframe?)而不仅仅是传递警报消息的文本.
有谁知道它是否可能或如何完成?
我在对话框中使用Alertify Jquery插件。问题是确认后的确认似乎不起作用:
<img onclick="go()" src="test.jpg">
<script type="text/javascript">
// confirm dialog
function go(){
alertify.confirm("Reset password?", function (e) {
if (e) {
// user clicked "ok"
secondconfirm();
} else {
// user clicked "cancel"
}
});
}
function secondconfirm(){
alertify.confirm("Password is changed<br>Mail it to the user?", function (e) {
if (e) {
//Done
alertify.success("Password reset and mailed to user.");
} else {
// user clicked "cancel"
alertify.success("Password reset.");
}
});
}
</script>
Run Code Online (Sandbox Code Playgroud)
我想以这种方式使用它,因为基于单击是或否,必须要问第二个问题。如果我这样使用它,第二个确认对话框会很快出现,然后弹出屏幕。更令人讨厌的是,覆盖屏幕其余部分的DIV保持不变,因此我什至不能在不刷新整个页面的情况下使用该网站。我想这与第一个对话框的淡出有关,也隐藏了第二个对话框。
如何解决呢?
我决定使用Alertify对我的代码进行修改和设计.我的旧代码:
<script type="text/javascript">
$('.ask').click(function(){
var answer = confirm('<?php echo $this->translate('Delete route?'); ?>');
return answer;
});
Run Code Online (Sandbox Code Playgroud)
当我按下确定时,php脚本会运行并删除记录.Javascript返回true或false.
我使用Alertify的问题是我甚至无法按下确定或取消,我的PHP脚本在此之前运行.这是代码:
$(".ask").click(function(event){
alertify.confirm("Are you sure you want to commit your reservation?", function (e) {
if (e) {
return true;
} else {
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
});
我看到一些有类似问题的人,我看到我需要使用防止默认值(这是有道理的)代码:
$(".ask").click(function(event){
event.preventDefault(); // cancel submit
alertify.confirm("Are you sure you want to commit your reservation?", function (e) {
if (e) {
return true; // submit form skipping jQuery bound handler
} else {
}
});
Run Code Online (Sandbox Code Playgroud)
});
在那种情况下,PHP脚本在我按下确定/取消之前没有运行但是当我按下其中一个按钮时它也没有运行.什么都没发生.有什么帮助吗?
我正在尝试在 React 中使用 ALERTIFYJS,但它的 alertify 警报不起作用。下面是代码
(window.alert 在我的浏览器上运行良好)
import alertify from 'alertifyjs';
clickHandle = () => {
alertify.alert('Alert Title', 'Alert Message!', function(){
alertify.success('Ok');
});
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有按钮“打开提示”的模式:
<div class="modal fade" id="test" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Arquivo</h4>
</div>
<div class="modal-body">
<a href="javascript:my_prompt();" class="button">Open prompt</a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Run Code Online (Sandbox Code Playgroud)
和my_prompt函数:
function my_prompt()
{
alertify.prompt( 'Prompt', function (e, str) {}, "" );
}
Run Code Online (Sandbox Code Playgroud)
当我使用$('#test').modal('show');和显示模态并单击以打开提示时,它们都会出现,但是Alertify不能进行编辑。如果我按ESC键,它们都会消失。
有人也有这个问题吗?有解决方案吗?
我是alertify.js的新手.我想要做的是,当用户点击链接时,浏览器应显示确认框.如果用户点击,则转到下一页.如果用户单击取消,则保持在同一页面上.是否可以使用alertify.js执行此操作?
这是我的HTML代码.
<a href="index.php" class="alert">Logout</a>
Run Code Online (Sandbox Code Playgroud)
这是我的JavaScript代码.
$(".alert").on('click', function(){
alertify.confirm("Are you sure?", function (e) {
if (e) {
return true;
} else {
return false;
}
});
});
Run Code Online (Sandbox Code Playgroud)
但问题是每当我点击链接时,我都会转到index.php页面,然后点击确认.
我正在使用AlertifyJQuery插件来显示alert,confirm, dialog框.
问题面临确认,它无法正常工作或取消点击
JS代码:
function myconfrm() {
var falgset = true;
alertify.confirm("Are you sure to delete this record.", function (e) {
if (e) {
// user clicked "ok"
falgset = false;
}
});
alert(falgset);
return falgset;
}
$("#btn").live('click', function (event) {
if (myconfrm()) {
// my ajax call
}
});
Run Code Online (Sandbox Code Playgroud) 所以我有这些代码行:
$('td').click(function (e) {
var test = "....";
var test2 = "....";
var test3 = "....";
SuppressWarning(test, test2, test3);
});
function SuppressWarning(test, test2, test3)
{
var reason = prompt("Why are you suppressing this warning?");
if(reason != "")
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
系统运行时,它会在提示符处停止,除非用户进行交互,否则不会继续执行if语句.但是,我想自定义警报框,所以我决定使用alertify.js.
所以我现在最终得到了这段代码:
$('td').click(function (e) {
var test = "....";
var test2 = "....";
var test3 = "....";
SuppressWarning(test, test2, test3);
});
function SuppressWarning(test, test2, test3)
{
var reason = alertify.prompt("Message", function (e, str) {
if (e) {
// user …Run Code Online (Sandbox Code Playgroud) 我想在 div 中“找到”带有 .removeRow 类的按钮后使用alertify.js
$(".removeRow").find("button").click(function(){
alertify.confirm("remove this field?", function (e) {
if (e) {
// user clicked "ok"
$(this).closest(".agrRow").remove();
}
});
});
Run Code Online (Sandbox Code Playgroud)
问题是在我调用alertify之后,我失去了“this”的值。如何将“this”传递到alertify函数中?