Search code examples
twitter-bootstrapfont-awesomebootbox

Bootbox and Font awesome icon in button


I'm using bootbox plugin for bootstrap modals. I would like to know how to put an F.A. icon inside a bootbox dialog button.

This is my code:

bootbox.dialog({
        className: "modal-danger nonumpad",
        closeButton: false,
        animate: false,
        title: '...',
        message: "...",
        onEscape: null,
        buttons: {
            refresh: {
                label: "Refresh",
                className: "btn-warning btn-lg pull-left",
                callback: function(){
                    return false;
                }
            },
            main: {
                label: "Setup",
                className: "btn-primary btn-lg",
                callback: function(){
                    return false;
                }
            }
        }
    });

I just need to append inside the bootbox buttons a <i> element with a custom class:

<i class="fa fa-check"></i>

Solution

  • I think you can. Label options of button supports HTML, not just text. So

    bootbox.dialog({
         className: "modal-danger nonumpad",
         closeButton: false,
         animate: false,
         title: '...',
         message: "...",
         onEscape: null,
         buttons: {
              refresh: {
                   label: "<i class=\"fa fa-check\"></i> Refresh",
                   className: "btn-warning btn-lg pull-left",
                   callback: function(){
                        return false;
                   }      
              }
          }
    });