Search code examples
javascriptmeteorbootbox

Bootbox HTML Render


What is the proper method to render HTML into a bootbox callback function?

The problem I'm running into is that I'm trying to make an HTML email on the callback and none of the HTML tags are rendering properly.

callback: function () {
   var text = "Greetings,<br /><br />" +

Thanks in advance.


Solution

  • Try to use Blaze.renderWithData or just Blaze.render to load a template containing your html inside the bootbox. Here is an example

    bootbox.dialog({
            message: "<div id='dialogAnchor'></div>",//I am not sure if it will be found. 
                                                     //You can just set your anchor div in the parent document
            title: "Such a nice modal!",
            animate: true,
            buttons: {
                danger: {
                    label: 'cancel',
                    className: "btn-default",
                    callback: function() {
    
                    }
                },
                success: {
                    label:'done',
                    className: "btn-success",
                    callback: function() {
                        Blaze.renderWithData(Template.YourHTML, {email:this.content}, $("#dialogAnchor")[0]);
                        //or alternatively
                        Blaze.render(Template.YourHTML, $("#dialogAnchor")[0]);
                    }}
                }});