【问题标题】:Setting title and labels in alertifyjs在 alertifyjs 中设置标题和标签
【发布时间】:2018-07-08 15:11:02
【问题描述】:

我使用 alertifyjs 创建了一个自定义确认对话框,并尝试设置标签和标题,但是,我似乎无法同时实现两者。请有人帮忙。

<html>

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/css/alertify.min.css" />
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/css/themes/bootstrap.min.css" />
  <script src="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/alertify.min.js"></script>

</head>

<body>

  <div style="display:none;">
    <div id="dlgContent">
      <p> Enter Value One </p>
      <input class="ajs-input" id="inpOne" type="text" value="Input One Default Value" />

      <p> Enter Value Two </p>
      <input class="ajs-input" id="inpTwo" type="text" value="Input two default Value" />

    </div>
  </div>

  <!-- the script  -->

  <script>
    var dlgContentHTML = $('#dlgContent').html();

    $('#dlgContent').html("");
    alertify.confirm(dlgContentHTML).set('onok', function(closeevent, value) {
      var inpOneVal = $('#inpOne').val();
      var inpTwoVal = $('#inpTwo').val();
      //updateListItems(inpOneVal,inpTwoVal);	

      if (inpOneVal == "test" && inpTwoVal == "test") {
        alertify.success('Successful');
      } else {
        alertify.error('Wrong')

      }
    }).set({title:"Update"},{labels:{ok:'Forward', cancel: 'Backward'}});
  </script>

</body>

</html>

这就是我尝试的方式

...}).set({title:"Update"},{labels:{ok:'Forward', cancel: 'Backward'}});

请有人告诉我如何实现这一点,因为我想为对话框设置自定义标题和标题。我一直在文档中,但无法实现我想要的。

【问题讨论】:

    标签: javascript jquery dialog alert


    【解决方案1】:

    你的语法错误

    改变

    .set({title:"Update"},{labels:{ok:'Forward', cancel: 'Backward'}});

    .set({title:"Update"}).set({labels:{ok:'Forward', cancel: 'Backward'}});

    <html>
    
    <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/css/alertify.min.css" />
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/css/themes/bootstrap.min.css" />
      <script src="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/alertify.min.js"></script>
    
    </head>
    
    <body>
    
      <div style="display:none;">
        <div id="dlgContent">
          <p> Enter Value One </p>
          <input class="ajs-input" id="inpOne" type="text" value="Input One Default Value" />
    
          <p> Enter Value Two </p>
          <input class="ajs-input" id="inpTwo" type="text" value="Input two default Value" />
    
        </div>
      </div>
    
      <!-- the script  -->
    
      <script>
        var dlgContentHTML = $('#dlgContent').html();
    
        $('#dlgContent').html("");
        alertify.confirm(dlgContentHTML).set('onok', function(closeevent, value) {
          var inpOneVal = $('#inpOne').val();
          var inpTwoVal = $('#inpTwo').val();
          //updateListItems(inpOneVal,inpTwoVal);	
    
          if (inpOneVal == "test" && inpTwoVal == "test") {
            alertify.success('Successful');
          } else {
            alertify.error('Wrong')
    
          }
        }).set({title:"Update"}).set({labels:{ok:'Forward', cancel: 'Backward'}});
      </script>
    
    </body>
    
    </html>

    【讨论】:

    • 谢谢它有效,我需要等待 7 分钟才能接受答案,但同时我已经投票了 :)
    • @Jackie 欢迎
    • 你能不能帮我解决这个问题(我正在尝试在编辑部分实现布局)-stackoverflow.com/questions/49515837/…
    • 你也知道是否可以从alertiifyJS对话框上的按钮中删除边框/后退,而只有文本,例如前进和后退
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多