我已经尝试了3个小时来让我的Alertify JS代码工作。我需要这些函数一个接一个地运行,并使prompt的答案成为一个全局变量,以便在另一个函数中使用。当我运行它时会发生什么,它会执行第一个提示,但我不会执行其他任何提示。我还是个编程新手,我敢打赌我做了一些愚蠢的事情。这就是我拥有的。
function appchange() {
alertify.prompt("Enter the number of the app you want to change. From left to right, 1-5.", ' '
, function(evt, a) { numb = a;
linkURL();
});
}
function linkURL() {
alertify.prompt("Enter the link you want the app to go to.", 'https://'
, function(evt, b) { url = b;
iconHTML();
});
}
function iconHTML() {
alertify.prompt("Enter the html of the icon from fontawesome.com/icons or you can use a capitol letter. CAN NOT BE A PRO ICON!", ' '
, function(evt, c) { icon = c;
finish();
});
}
function finish() {
}如果有人能纠正我做错了什么,那就太棒了。谢谢!
发布于 2019-09-16 00:17:30
从警报文档..。Alertify examples (RTFM)
/**
* Dialogs factory
*
* @name {string} Dialog name.
* @Factory {Function} Dialog factory function.
* @transient {Boolean} Indicates whether to create a singleton or transient dialog.
* @base {String} The name of an existing dialog to inherit from.
*
* alertify.dialog(name, Factory, transient, base)
*
*/
if(!alertify.myAlert){
//define a new dialog
alertify.dialog('myAlert',function factory(){
return{
main:function(message){
this.message = message;
},
setup:function(){
return {
buttons:[{text: "cool!", key:27/*Esc*/}],
focus: { element:0 }
};
},
prepare:function(){
this.setContent(this.message);
}
}});
}
//launch it. NOTE THIS IS A STRING WITH TEXT BUT COULD ALSO BE A STRING
//WITH THE HTML OF YOUR FORM
alertify.myAlert("Browser dialogs made easy!");你也可以尝试这样的东西--我今天很懒,所以你可以通过谷歌的向导来寻找一个可用的表单样本maybee。
<template id="myform">
<h2>Flower</h2>
<form name="free_willy" >
<input name="something" id="something" type text>
</form>
</template>除了现代标记(参见Template Tag )之外,您还可以使用:
<div id="myform" hidden>
<form> ....
</form>
</div> 现在你可以这样做了
var form_src=document.getElementById("myform").innerHTML;
alertify.myAlert(form_src);https://stackoverflow.com/questions/57945681
复制相似问题