Disable edit mode in EJ2 JavaScript In place editor control
19 Apr 20233 minutes to read
The edit mode of In-place Editor can be disabled by setting the disabled property value to true
. In the following sample, when check or uncheck the checkbox, In-place Editor control will disable or enable the edit mode.
ej.base.enableRipple(true);
var CheckBoxObj = new ej.buttons.CheckBox({ label: 'Disable', checked: false, change: onChange });
CheckBoxObj.appendTo('#enable');
//Initialize In-place Editor control
editObj = new ej.inplaceeditor.InPlaceEditor({
mode: 'Inline',
value: 'Andrew',
model: {
placeholder: 'Enter some text'
}
});
//Render initialized In-place Editor control
editObj.appendTo('#element');
function onChange(e) {
editObj.disabled = e.checked;
editObj.dataBind();
}
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 In-place Editor</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript In-place Editor Control">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/28.1.33/material.css" rel="stylesheet">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<table class="table-section">
<tbody><tr>
<td> Disabled: </td>
<td>
<input id="enable" type="checkbox">
</td>
</tr>
<tr>
<td class="sample-td"> Enter your name: </td>
<td class="sample-td">
<div id="element"></div>
</td>
</tr>
</tbody></table>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>