在 alertifyjs 中设置标题和标签

Jac*_*kie 2 javascript jquery alert dialog

我使用 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>
Run Code Online (Sandbox Code Playgroud)

这就是我尝试的方式

...}).set({title:"Update"},{labels:{ok:'Forward', cancel: 'Backward'}});
Run Code Online (Sandbox Code Playgroud)

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

Nul*_*ter 6

你的语法错误

改变

.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>
Run Code Online (Sandbox Code Playgroud)