JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://http://code.jquery.com/jquery-2.1.3.js"></script>
<script src="http://castiel.go.ro/book/jquery-ui.js"></script>
<link rel="stylesheet" href="http://castiel.go.ro/book/jquery-ui.css">
<div id="add-booking-form" title="Add new Booking" class="modal-form">
<p class="validateTips">All form fields are required.</p>
<fieldset>
<label for="sdate">Start date</label>
<input type="text" name="sdate" id="sdate" value="" class="ui-widget-content modal-input dpicker" tabindex="-1" autofocus="autofocus" />
<label for="stime">Start time</label>
<input type="text" name="stime" id="stime" value="" class="text ui-widget-content modal-input" />
<label for="edate">End Date</label>
<input type="text" name="edate" id="edate" value="" class="text ui-widget-content modal-input" />
<label for="etime">End Time</label>
<input type="text" name="etime" id="etime" value="" class="text ui-widget-content modal-input" />
<label for="reason">Reason</label>
<input type="text" name="reason" id="reason" value="" class="text ui-widget-content modal-input" />
</fieldset>
</div>
<button class="edit-booking">Show Dialog</button>
JavaScript
$(function () {
$(".dpicker").datepicker({
numberOfMonths: 2,
dateFormat: 'd M yy',
showButtonPanel: true
});
var new_dialog = function (type, book) {
var myButtons, dlg, type;
var sdate, stime, edate, etime, reason;
var config = {
autoOpen: true,
height: 500,
width: 350,
modal: false,
close: function () {
dlg.remove();
}
};
if (type === 'Create-Book') {
dlg = $("#add-booking-form").clone();
sdate = dlg.find(("#sdate"));
stime = dlg.find(("#stime"));
edate = dlg.find(("#edate"));
etime = dlg.find(("#etime"));
reason = dlg.find(("#reason"));
config.title = "Add Booking";
myButtons = {
buttons: {
"Add Booking": save_data_book,
"Cancel": function () {
dlg.dialog("close");
}
}
};
}
dlg.dialog(config, myButtons);
function save_data_book() {
dlg.remove();
}
};
$(".edit-booking").click(function (event) {
new_dialog('Create-Book', $(this));
return false;
});
});