admin管理员组

文章数量:1327849

I have created a custom confirm dialog using alertifyjs and am trying to set the labels and title, however, I can't seem to achieve both at once. Please can someone help.

<html>

<head>
  <script src=".1.1/jquery.min.js"></script>
  <link rel="stylesheet" href="/[email protected]/build/css/alertify.min.css" />
  <link rel="stylesheet" href="/[email protected]/build/css/themes/bootstrap.min.css" />
  <script src="/[email protected]/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>

I have created a custom confirm dialog using alertifyjs and am trying to set the labels and title, however, I can't seem to achieve both at once. Please can someone help.

<html>

<head>
  <script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr/npm/[email protected]/build/css/alertify.min.css" />
  <link rel="stylesheet" href="https://cdn.jsdelivr/npm/[email protected]/build/css/themes/bootstrap.min.css" />
  <script src="https://cdn.jsdelivr/npm/[email protected]/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>

This is how I have attempted

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

Please can someone tell me how I can achieve this because I want to set custom title and title for the dialog box. I been on the documentation but wasn't able to achieve what I wanted.

Share asked Jul 8, 2018 at 15:11 JackieJackie 4571 gold badge10 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Your syntax is wrong

Change

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

to

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

<html>

<head>
  <script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr/npm/[email protected]/build/css/alertify.min.css" />
  <link rel="stylesheet" href="https://cdn.jsdelivr/npm/[email protected]/build/css/themes/bootstrap.min.css" />
  <script src="https://cdn.jsdelivr/npm/[email protected]/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>

本文标签: javascriptSetting title and labels in alertifyjsStack Overflow