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

function to retreive response from dialog #383

Closed dnsBlah closed 5 years ago

dnsBlah commented 5 years ago

Hi all,

I'm looking for a way to get response from the dialog in my function. I have some select boxes and when adding something I use this dialog function to request some additional information. On closing I'd like to pass back the information so I can do something on it.

I have a on.('change' function on the select, with a function like:

$('#boxx').on('change', function(e) {
...
var additionalInfo = getAdditional($(this).val());
...
});

function getAdditional(curField) {
var tDesc = '';
BootstrapDialog.show({
    title: 'Additional info for ' + curField,
    message: '<input type="text" id="add_info">',
    buttons: [
        {
            label: 'Ok',
            cssClass: 'btn-primary',
            action: function(dialog) {
                 tDesc = $('#add_info').val();
                 dialog.close();
            }
        }
     ]
});

return tDesc;
}

But ofcourse the dialog is running async on the code.. Does anyone has any advice for me?

dnsBlah commented 5 years ago

nvm