How to create custom modal popup in bootstrap?
Add HTML Modal div
<!-- Modal --> <div class="modal fade" id="confirm-modal" 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">Confirmation</h4> </div> <div class="modal-body"> <p id="modal-msg">Confirm message will append here.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" id="btnok">Ok</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> </div> </div> </div> </div> <!-- Modal --> <div class="modal fade" id="alert-modal" 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">Alert!</h4> </div> <div class="modal-body"> <p id="modal-msg-alert">Alert message will append here.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Ok</button> </div> </div> </div> </div>
Add JavaScript functions
function ModalConfirm(msg, postbackurl) { $('#modal-msg').html(msg); $('#confirm-modal').modal({ backdrop: 'static', keyboard: false }) .one('click', '#btnok', function () { if (postbackurl != '') { window.location = postbackurl; } }); } function ModalAlert(msg) { $('#modal-msg-alert').html(msg); $('#alert-modal').modal({ backdrop: 'static', keyboard: false }) }
Call these JavaScript functions to show alert
Alert Popup
Confirm Popup
0 comments :
Post a Comment