jquery - Calling a function on click of OK button in a pop up in the Javascript -
i have function in javascript displays pop-up. doing in sitecore based mvc project , hence can not events in normal way following practice followed in project.
if (iswarning) { $('#warning').modal('show'); $("#warningdisplay").val("true"); }
now modal shown without problem , modal has ok button (only 1 button). clicking on ok should call function below.
function dialogokclick() { $('#warning').modal('close'); $('#calbutton').click(); }
basically, intend in function is, close pop , trigger click of home page.
how call function on click of ok in pop displayed result of first function? modal pop up.
edit:
we use infodialogviewmodel in cshtml file defining warning dialog , contents.
<!doctype html> <html lang="en"> <head> <title>bootstrap example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <script> $(document).ready(function () { $('#warning').modal({ backdrop: 'static', keyboard: false }) .one('click', '#btnok', function (e) { $('#calbutton').trigger('click'); }); $('#calbutton').click(function () { alert('function'); }); }); </script> <body> <button id="calbutton">add</button> <div class="container"> <!-- trigger modal button --> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#mymodal">open modal</button> <!-- modal --> <div class="modal fade" id="warning" role="dialog"> <div class="modal-dialog"> <!-- modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">modal header</h4> </div> <div class="modal-body"> <p>some text in modal.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal" id="btnok">ok</button> </div> </div> </div> </div> </div> </body> </html>
Comments
Post a Comment