1

我已经尝试了 3 个小时来让我的 Alertify JS 代码正常工作。我需要这些函数彼此紧随其后,并使提示的答案成为我可以在另一个函数中使用的全局变量。当我运行它时会发生什么,它会执行第一个提示,但我不执行任何其他提示。我对编码还是很陌生,我敢打赌我做了一些愚蠢的事情。这就是我所拥有的。

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() {
}

如果有人可以解决我做错的事情,那就太棒了。谢谢!

4

1 回答 1

0

来自警报文档...警报示例(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!");

你也可以尝试这样的事情——我今天很懒,所以找一个谷歌奇才的工作表格样本。

 <template id="myform">
    <h2>Flower</h2>
    <form name="free_willy" >  
       <input name="something" id="something" type text>
    </form>
 </template>

而不是现代标签(请参阅模板标签),您还可以使用:

     <div id="myform" hidden>
        <form>  ....
        </form>
     </div>  

现在你可以做这样的事情

    var form_src=document.getElementById("myform").innerHTML;
    alertify.myAlert(form_src);
于 2019-09-15T16:17:29.937 回答