简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM