I am working on a project where i have to perform actions like social media, i stuck on a stage where i have to comment and then i have to reset that editable div. Editable Div code:
<div id="txtComment" contenteditable="true" class="form-control txtComment" style="height: 156px; margin-bottom: 10px;">
My button for calling comment function Code:
<input type="button" value="POST" ng-click="comment(<?php echo $itemId ?>,<?php echo $itemDesc ?> ,user_comment,0,0,mood)">
my function:
$scope.comment=function (itemid, itemdescid,user_comment,replyId,parentcomId,mood)
{
var feeling="";
//console.log(mood);
if (typeof mood !== "undefined")
{
feeling=mood;
//console.log(mood+"test");
}
var comm="";
if(replyId==0)
{
comm=$("#txtComment").html();
}else if(replyId == parentcomId)
{
comm=$("#"+parentcomId+"comment").html();
//console.log(comm);
} else
{
comm=$("#"+replyId+"comment").html();
}
console.log(comm);
//console.log(feeling);
var req = {
method:"POST",
data:{item_Id:itemid, item_desId:itemdescid, comment:comm,commentReplyId:replyId,parent_commentId:parentcomId,User_feeling:feeling,userId:$scope.id},
url:"<?php echo base_url()?>index.php/ItemImportance/Comment",
headers: {
'Content-Type': 'application/json'
},
};
$http(req).then(function (response) {
if (response.data !=null)
{
if(response.data.msg !=null)
{
alert(response.data.msg);
}
else
{
//var scopeNmae="item"+"_"+itemid+"_"+itemdescid;
// console.log(scopeNmae);
//$scope[scopeNmae]=response.data;
//console.log(response.data);
// window.location.reload();
$scope.itemcomments=response.data;
//eraseText();
}
} else
{
}
}, function (response) {
console.log(response)
});
}
what i have to do is just empty my editable div after i click on comment button! please help me as fast as you can.