Hello,
So I have this comment box on a dynamic page, everything used to work just fine, users could post a comment along with the nickname of their choice, only now it no longer works !
It shows the message error everytime I try to post something.
I’ve already checked permissions, everything is set on “everyone”.
Here is my code :
$w("#dataset3").onReady(() => {
const msg = $w("#dataset3").getCurrentItem();
$w("#html1").onMessage((event) => {
if (event.data === "ready") {
$w("#html1").postMessage(msg.longDescription);
}
//Set the value for the rich text field of the dataset's
//current item to be the data in the HTML element
const dataWithFixedLinkStyles = event.data.replace(/\<a/g, `<a style="color:#F78E05;"`);
$w('#dataset3').setFieldValue("commentRich", dataWithFixedLinkStyles);
$w("#repeater2").onItemReady(($w, itemData, index) => {
$w('#dataset3').setFieldValue('item', $w('#text54').text);
});
let url = wixLocation.url;
$w('#dataset3').setFieldValue('url', url);
$w('#dataset3').setFieldValue('reference', $w('#input2').value)
.then((res) => {
$w("#dataset3").save()
.then(() => {
wixLocation.to(wixLocation.url);
});
});
});
});
//refreshes comments + goes to top of comment box upon submitting a message
export function button43_click(event, $w) {
//POST A COMMENT
//post a comment and get the item's ID + title + URL
$w("#html1").postMessage("save");
}
I use the CKeditor, it works fine on 2 other pages, but on this page it doesn’t work anymore.
CKeditor code in HTML component:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="//cdn.ckeditor.com/4.6.2/basic/ckeditor.js"></script>
<script type="text/javascript">
function init() {
window.onmessage = (event) => {
if (event.data == "save") {
window.parent.postMessage(CKEDITOR.instances.CK1.getData(),"*");
} else {
CKEDITOR.instances.CK1.setData(event.data);
window.parent.postMessage("set","*");
}
}
}
</script>
</head>
<body onload="init();">
<textarea placeholder ="test" name="editor1" id="CK1"></textarea>
<script>
CKEDITOR.replace("editor1");
window.parent.postMessage("ready", "*");
</script>
</body>
</html>
Link to the page :
Please help me as this is of the utmost importance for my website !