Integration in EJ2 JavaScript In place editor control

19 Apr 20233 minutes to read

The In-place Editor supports adding HTML5 input controls using the template property. The Template property can be given as either a string or a query selector.

As a string

The HTML element tag can be given as a string for the template property. Here, the input is rendered as an HTML template.

template: "<div><input type='text' id='name'></input></div>"

As a selector

The template property also allows getting template content through query selector. Here, the input wrapper element ‘ID’ attribute is specified in the template.

template: "#date"

Template mode, the value property not handled by the In-place Editor control. So, before sending a value to the server, you need to modify at actionBegin event, otherwise, an empty string will pass. In the following template sample, before submitting a data to the server, event argument and value property content updated in the actionBegin event handler.

ej.base.enableRipple(true);

//Initialize In-place Editor control
var editObj = new ej.inplaceeditor.InPlaceEditor({
    mode: 'Inline',
    template: '#date',
    value: '2018-05-23',
    actionBegin: function(e) {
        var value = editObj.element.querySelector('#date').value;
        editObj.value = value;
        e.value = value;
    }
});

//Render initialized In-place Editor control
editObj.appendTo('#element');
<!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/25.1.35/material.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/25.1.35/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">
        <span class="content-title"> Select date: </span>
        <div id="element"></div>
    </div>
    <div id="html-template" style="display: none">
        <input id="date" value="2018-05-23" type="date">
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

See Also