Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BootstrapDialog confirm dynamic callback with extra parameters #329

Open
kuntalbose opened this issue Feb 16, 2017 · 3 comments
Open

BootstrapDialog confirm dynamic callback with extra parameters #329

kuntalbose opened this issue Feb 16, 2017 · 3 comments

Comments

@kuntalbose
Copy link

kuntalbose commented Feb 16, 2017

I think this is not an issue ,its my custom requirement but I can't any other better place to post thats why I post this here .currently I write bellow core , but I want dome more parameter in b1checkConfirm(result,param1,param2)...etc or object like b1checkConfirm(result,{id:1,name:"name"}) is it possible? if yes .how?

<head>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css" rel="stylesheet"/>
 <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>
<script>

function callconfirm(cb)
{
   // var isConfirmed
     BootstrapDialog.confirm({
            title: 'WARNING',
            message: 'Warning! Drop your banana?',
            type: BootstrapDialog.TYPE_WARNING, // <-- Default value is BootstrapDialog.TYPE_PRIMARY
            closable: false, // <-- Default value is false
            draggable: false, // <-- Default value is false
            btnCancelLabel: 'Do not drop it!', // <-- Default value is 'Cancel',
            btnOKLabel: 'Drop it!', // <-- Default value is 'OK',
            btnOKClass: 'btn-warning', // <-- If you didn't specify it, dialog type will be used,
            callback:cb /*function(result) {
                // result will be true if button was click, while it will be false if users close the dialog directly.
                if(result) {
                  return true;
                }else {
                    return false;
                }
            }*/
        });

}

function b1checkConfirm(result)
{
    //callconfirm();
    console.log("B1 click and result is "+result);
}
function b2checkConfirm(result)
{
    //callconfirm();
    console.log("B2 click and result is "+result);
}
</script>
</head>
<body>
<button type="button"  onclick="callconfirm(b1checkConfirm)" style="height: 50px;width: 50px" >B1</button>
<button type="button"  onclick="callconfirm(b2checkConfirm)" style="height: 50px;width: 50px" >B2</button>
</body>
@kuntalbose kuntalbose changed the title BootstrapDialog confirm callback with extra parameters BootstrapDialog confirm dynamic callback with extra parameters Feb 16, 2017
@nakupanda
Copy link
Owner

nakupanda commented Feb 20, 2017

There is no way to have extra parameters applied to the callback function.

If you want to specify / bind something to the callback function, I think you can see this example: http://jsfiddle.net/bn8hhea2/2/

@kuntalbose
Copy link
Author

Thanks Dante for your reply ,the situation is I have bind some records in a table and each record has a delete button I want to notify user with a confirmation and if user confirm the data will be delete .that's why
I want to pass the record ID as parameter to to the call back method.If you have any other idea please suggest .

@nakupanda
Copy link
Owner

No idea so far :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants