javascriptjquerylaravelbootbox

Change ok cancel option of bootbox to yes & no


Can anyone tell me how I should change the ok & cancel option of the Bootbox to yes & no.

function deletelaw(id) {
  bootbox.confirm('Are you sure you want to delete?', function(result) {
    if (result) {
      $("#deletelaw_" + id).hide();
      $(".law1_" + id).prop("checked", false);
      var splits = $("#laws_assigned1").val().split(",");

      var finalSplit = [];
      for (var i = 0; i < splits.length; i++) {
        if (id != splits[i]) {
          finalSplit.push(splits[i]);
        }
      }
      $("#laws_assigned1").val(finalSplit.join());
    }
  });
}

Solution

  • You could pass buttons object to change the buttons label and style this way :

    bootbox.confirm({
      message: "Are you sure you want to delete?",
      buttons: {
        confirm: {
          label: 'Yes',
          className: 'btn-class-here'
        },
        cancel: {
          label: 'No',
          className: 'btn-class-here'
        }
      },
      callback: function (result) {
        if (result) {
          $("#deletelaw_" + id).hide();
          $(".law1_" + id).prop("checked",false);
          var splits = $("#laws_assigned1").val().split(",");
    
          var finalSplit = [];
          for (var i = 0; i < splits.length; i++) {
            if (id != splits[i]) {
              finalSplit.push(splits[i]);
            }
          }
          $("#laws_assigned1").val(finalSplit.join());
        }
    
      }
    });