JSFiddle - React, Tailwind, and code Playground
HTML
<!--Wrapper div-->
<div id="wrapper">
<!--Inbox list and button to add a card-->
<div id="inboxList" class="cellContainer">
<p style="display: inline">Inbox</p>
<!--Button to add a Card-->
<input type="button" id="AddCardBtn" value="+ Add a Card..." />
<hr class="fancy-line" />
<br/>
<!--Card div-->
<div id="userAddedCard">
<br/>
<div></div>
</div>
</div>
</div>
<!--Modal Dialog-->
<div id="modalDialog">
<form>
<input type="button" id="Getbtn" value="Get value" />
<hr/>
<br/>
<label>Add checkBox</label>
<br />
<input type="text" id="checkBoxName" />
<input type="button" id="btnSaveCheckBox" value="_Ok" />
<div id="boxs"></div>
<hr class="fancy-line" />
</form>
</div>
<!--Reference to Jquery-->
CSS
/*Style of a body*/
body {
background-color: #f4f4f4;
}
.allcheckbox {
border: 2px solid black;
border-radius: 4px;
margin-bottom: 10px;
width:80%;
margin-left:auto;
margin-right:auto;
}
.allcheckbox label
{
word-wrap: break-word;
}
/*Style of a Wrapper*/
#wrapper {
margin-top: 3%;
margin-right: 20%;
height: 715px;
min-width: 300px;
min-height: 715px;
background-color: #00CCFF;
box-shadow: 7px 7px 7px #828282;
border-radius: 6px;
}
/*Style of a inbox list*/
#inboxList {
width: 275px;
height: 700px;
background-color: #f0f0f0;
border: 1px solid black;
margin-left: 0.5%;
margin-top: 0.4%;
border-radius: 10px;
box-shadow: 7px 7px 7px #828282;
overflow: auto;
}
/*Style of a Modal Dialog*/
#modalDialog {
display: none;
background-color: white;
border: solid black 2px;
border-radius: 10px;
overflow: auto;
box-shadow: 7px 7px 7px #828282;
}
/*Style of a card*/
.cellContainer .sortable-div {
background: whitesmoke;
width: 260px;
height: 150px;
margin-left: 2.3%;
border-radius: 10px;
border: 2px solid black;
box-shadow: 0px 7px 7px #828282;
margin-bottom: 1%;
}
JavaScript
$(function () {
// Click function to add a card
var $div = $('<div />').addClass('sortable-div');
var cnt = 0,
$currentTarget;
$('#AddCardBtn').click(function () {
var $newDiv = $div.clone(true);
cnt++;
$newDiv.prop("id", "div" + cnt);
$newDiv.data('checkboxes', []);
$('#userAddedCard').append($newDiv);
// alert($('#userAddedCard').find("div.sortable-div").length);
});
// Double click to open Modal Dialog Window
$('#userAddedCard').dblclick(function (e) {
$currentTarget = $(e.target);
$('#modalDialog').dialog({
modal: true,
height: 600,
width: 500,
position: 'center'
});
return false;
});
$("#Getbtn").on("click", function () {
$('#modalDialog').dialog("close");
});
// Add a new checkBox
$('#btnSaveCheckBox').click(function () {
addCheckbox($('#checkBoxName').val());
$('#checkBoxName').val("");
});
function addCheckbox(name, status) {
status = status || false;
var container = $('#boxs');
var inputs = container.find('input');
var id = inputs.length + 1;
var data = {
status: status,
name: name
};
var div = $('<div />', { class: 'allcheckbox' });
$('<input />', {
type: 'checkbox',
id: 'cb' + id,
value: name
}).prop('checked', status).on('change', function () {
data.status = $(this).prop('checked');
}).appendTo(div); /* set checkbox status and monitor changes */
$('<label />', {
'for': 'cb' + id,
text: name
}).appendTo(div);
div.appendTo(container);
}
});