I tried following solution and it worked .
<textarea name="txtDesc<?php echo $i;?>" id="txtDesc<?php echo $i;?>" class="ckeditor" rows="5" cols="17" ><?php echo $txtDesc?></textarea>
<script>
CKEDITOR.replace("txtDesc<?php echo $i;?>");
CKEDITOR.add
//CKEDITOR.replace('txtDesc0');
</script>
If there is only 1 ckEditor
for (instance in CKEDITOR.instances) {
CKEDITOR.instances[instance].on("instanceReady", function () {
//set keyup event
this.document.on("keyup", function () { CKEDITOR.instances[instance].updateElement(); });
//and paste event
this.document.on("paste", function () { CKEDITOR.instances[instance].updateElement(); });
});
}
If there are more than 1 ckEditor(in my case 2)
CKEDITOR.instances["txtDesc0"].on("instanceReady", function () {
this.document.on("keyup", function () { CKEDITOR.instances["txtDesc0"].updateElement(); });
this.document.on("paste", function () { CKEDITOR.instances["txtDesc0"].updateElement(); });
this.document.on("cut", function () { CKEDITOR.instances["txtDesc0"].updateElement(); });
});
CKEDITOR.instances["txtDesc1"].on("instanceReady", function () {
this.document.on("keyup", function () { CKEDITOR.instances["txtDesc1"].updateElement(); });
this.document.on("paste", function () { CKEDITOR.instances["txtDesc1"].updateElement(); });
this.document.on("cut", function () { CKEDITOR.instances["txtDesc1"].updateElement(); });
});