nakupanda / bootstrap3-dialog

Make use of Twitter Bootstrap's modal more monkey-friendly.
https://nakupanda.github.io/bootstrap3-dialog/
1.89k stars 664 forks source link

Patch: assign custom ID to dialog #148

Open rgasch opened 9 years ago

rgasch commented 9 years ago

Please find a little patch below which allows you to set a custom-ID for the generated modal dialog:

diff --git a/themes/DV1/js/bootstrap-dialog.js b/themes/DV1/js/bootstrap-dialog.js index 9cb1ab5..f53d366 100644 --- a/themes/DV1/js/bootstrap-dialog.js +++ b/themes/DV1/js/bootstrap-dialog.js @@ -166,7 +166,7 @@ * ================================================ */ var BootstrapDialog = function(options) { this.defaultOptions = $.extend(true, {

I should note that I'm not a jquery pro, but this seems to work for me. If you find this is correct & useful, please consider merging this patch.

nakupanda commented 9 years ago

Hi,

BootstrapDialog should had made assigning custom id to dialog possible.

                var dialogId = 'my-dialog-1';
                var dialog = new BootstrapDialog({
                    id: dialogId,
                    title: 'Set custom id for your dialog',
                    message: 'Check out the dialog you have created and see if the id is set as expected.'
                });
                dialog.open();

You can view an example here: http://nakupanda.github.io/bootstrap3-dialog/play/custom-dialog-id.html

nakupanda commented 9 years ago

If no custom id was set at dialog instantiating time, BootstrapDialog.newGuid() will be used. If custom id was set just like above, it will be used as the dialog id.