Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@GaryRogers
Created August 12, 2014 16:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaryRogers/1ff32f3b27f4c4e52d55 to your computer and use it in GitHub Desktop.
Save GaryRogers/1ff32f3b27f4c4e52d55 to your computer and use it in GitHub Desktop.
Using Forms with Bootstrap-Dialog

Using forms with Bootstrap-Dialog

var alertMessage = "";
var formTemplate = Backbone.Marionette.TemplateCache.get('#myTemplate');
var formString = formTemplate({ defaultDate: moment().add(90, 'days').format('YYYYMMDD') });

// remove the newlines. Bootstrap-Dialog doesn't like them (turns them into <br>'s)
formString = formString.replace(/[\n]/g, '');

alertMessage = formString;

BootstrapDialog.show({
    title: 'Alert',
    message: alertMessage,
    buttons: [
        {
            label: 'Save',
            cssClass: 'btn-primary',
            autospin: true,
            action: function(dialogItself) {
                var inputData = {};
                dialogItself.$modalBody.find(':input').each( function() {
                    inputData[$(this).attr('name')] = $(this).val().trim();
                });
                App.vent.trigger("modalDialog:" + button, inputData);
                    setTimeout(function(){
                    dialogItself.close()
                }, 2000);
            }
        },
        {
            label: "Cancel",
            cssClass: 'btn-primary',
            action: function(dialogItself){
                dialogItself.close();
            }
        }
    ]
});
@mikael-titinovskii
Copy link

tnx, needed that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment