JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://twitter.github.com/bootstrap/1.4.0/bootstrap-modal.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.css">
<button type="button" id="delete_btn" class="btn">Delete</button>
CSS
.custom-confirm{
width:250px;
min-height:120px;
top: 45%;
left:45%;
margin:-50px 0px 0px -50px;
z-index:12000;
}
.custom-confirm .modal-body{
font-size:14px;
font-weight: bold;
text-align: center;
}
.custom-confirm .controls{
width: 150px;
margin:0 auto;
margin-top: 20px;
}
.controls button{
margin-right: 10px;
}
JavaScript
$('#delete_btn').click(function(){
var msg = 'Are you sure you want to delete action?';
customConfirm(msg, function(){alert('id deleted')},function(){alert('user pressed Cancel button')});
});
function customConfirm(message, true_func, false_func){
var container = document.createElement('div');
//template for modal window
container.innerHTML += '<div class="modal custom-confirm">'+
'<div class="modal-body">' +
'<div>' + message + '</div>' +
'<div class="controls">'+
'<button type="button" class="btn primary">OK</button>' +
'<button type="button" class="btn">Cancel</button>' +
'</div>' +
'</div>' +
'</div>';
//modal window
var modal = container.firstChild;
container = document.createElement('div');
container.innerHTML = '<div class="modal-backdrop in"></div>';
//dark background
var background = container.firstChild;
//get click OK button
var ok = modal.getElementsByTagName('button')[0];
ok.onclick = function() {
modal.parentNode.removeChild(modal);
document.body.removeChild(background);
true_func();
}
//get click Cancel button
var cancel = modal.getElementsByTagName('button')[1];
cancel.onclick = function() {
modal.parentNode.removeChild(modal);
document.body.removeChild(background);
false_func();
}
document.body.appendChild(background);
document.body.appendChild(modal);
}