Mike
Mike

Reputation: 269

Bootbox callback function not being called

I am trying to use Bootbox within an Angular2 application. I have the following code:

  bootbox.confirm({
      message: "Are you sure you want to complete this action?",
      buttons: {
          confirm: {label: 'Yes', className: 'btn-success'},
          cancel: {label: 'No', className: 'btn-danger'}
      },
      callback: function (result: any) {
          console.log('Response equals: ' + result);
      }
  });

The confirm box displays correctly when called and when clicking on either the "yes" or "no" button the confirm box disappears as it should. However, the callback function is not firing because I'm not getting the console message.

This is my first attempt trying to inject Bootbox into an application so I'm not sure why the callback function is not being called.

Any ideas?

Upvotes: 0

Views: 1021

Answers (1)

Sandeep Ingale
Sandeep Ingale

Reputation: 438

Have you tried with function(result) remove ':any'.

bootbox.confirm({
    message: "This is a confirm with custom button text and color! Do you like it?",
    buttons: {
        confirm: {
            label: 'Yes',
            className: 'btn-success'
        },
        cancel: {
            label: 'No',
            className: 'btn-danger'
        }
    },
    callback: function (result) {
        console.log('This was logged in the callback: ' + result);
    }
});

http://bootboxjs.com/examples.html#bb-confirm-dialog. Call back takes only one argument that is result.

Upvotes: 1

Related Questions