Your logic is bit wrong here.
Your first
click
event
$('#datatable tbody').on('click', 'td:nth-child(1), td:nth-child(5), td:nth-child(8), td:nth-child(11)', function (event) {
and the 2nd
click
event inside the
Editable()
function
$('#datatable tbody').on('click', 'td:nth-child(1), td:nth-child(5), td:nth-child(8), td:nth-child(11)', function () {
are both same. So, what you can do based on your logic is just remove the 2nd duplicate click event inside the
Editable()
function like:
$('#datatable tbody').on('click', 'td:nth-child(1), td:nth-child(5), td:nth-child(8), td:nth-child(11)', function (event) {
if ($("#ValBool").val() == "false") {
Editable(this);
} else {
event.stopImmediatePropagation();
alert("Not allowed");
}
});
function Editable(obj) {
var x = $(".itemEdit").length;
var getData = $(obj).html();
if (x == 0) {
$(obj).empty().html('<input type="text" value="' + getData + '" class="itemEdit" id="dataField"/>');
$('.itemEdit').focus();
}
}
Let me know if you are still facing any issues.