javascripthtmlbootbox

Bootbox: Make the default button work with the ENTER key?


As the title suggests, I want to add the Enter key as an event handler for Bootbox.js. When you an alert() popup is called, you can press enter to dismiss it, but that is not the case with Bootbox.js. I do not know how to get access to the button inside Bootbox.js to add an event handler. Any suggestions?


Solution

  • In order for the button to take focus, it should be defined with the "btn-primary" class name:

    className:
    main: {
          className: "btn-primary",  ...
    }