Bootstrap Modal Base
HTML
<link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css">
<link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/bootstrap-responsive.css">
<link rel="stylesheet" href="http://jschr.github.io/bootstrap-modal/css/bootstrap-modal.css">
<script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap.js"></script>
<script src="http://jschr.github.io/bootstrap-modal/js/bootstrap-modalmanager.js"></script>
<script src="http://jschr.github.io/bootstrap-modal/js/bootstrap-modal.js"></script>
<div id="d_name_modal_div" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="d_name_modal_label" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">Ă—</button>
<h3 id="d_name_modal_label">Dashboard Name</h3>
</div>
<div class="d_name_modal_body">
<p>Enter name of the dashboard you want to add this graph to :-</p>
<p>
<label>Dashboard Name:</label>{{form1.dashboard_name}}</p>
<input type="text" id="dashboard_name" />
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button id="d_name_modal_submit" class="btn btn-primary">Submit</button>
</div>
</div>
<input type="image" value="Add to Dashboard" id="add_to_dash" height=40 width=40></input>
JavaScript
function dashboard_submit() {
alert('Dashboard submit');
var dfd = new $.Deferred();
dashboard_name = 'ram';
$("#d_name_modal_div").modal({
backdrop: false
});
dfd.done(function(){
var dn = $('#dashboard_name');
dn.val('booooooo I recived the data now I can open the dialog');
dn.text(dn.val());
$("#d_name_modal_div").modal("show");
});
dfd.resolve();
return dfd;
}
function wtf() {
var dfd = $.Deferred();
$('#d_name_modal_submit').on('click', function () {
dashboard_name = $('#dashboard_name').val();
alert(dashboard_name);
if ( !$.trim(dashboard_name) ) {
alert('Dashboard name is mandatory.');
return false;
} else {
dfd.resolve();
alert('success');
return dfd;
}
});
}
$('#add_to_dash').click(function (e) {
alert('Add to dash start');
dashboard_submit().done(function () {
wtf();
});
alert('Add to dash end');
});