Hurray it works !!!
I don’t know what was wrong but this works :
$w("#dataset3").onReady( () => {
$w('#dataset3').setFieldValue('reference', $w('#input2').value);
});
Hurray it works !!!
I don’t know what was wrong but this works :
$w("#dataset3").onReady( () => {
$w('#dataset3').setFieldValue('reference', $w('#input2').value);
});
Awesome!
Now to filter comments according to the ID !
I tried this, but no dice :
//LIST OF COMMENTS
$w("#dataset2").onReady( () => {
let filter = wixData.filter();
filter = filter
.eq("reference", $w("#input2").value);
});
stupid me, I forgot one string, this works now !
//POST A COMMENT
$w("#dataset2").onReady( () => {
$w('#dataset2').setFieldValue('reference', $w('#input2').value);
});
});
Wow thanks a lot man, now I have my very own comment box !
Now what I’d need is to display the number of comments.
I’m so glad that it worked.
All you have to do is to count any field on your commentaires db and to put it some textbox etc. which this time i have no idea on how to
Yea, I don’t know how to show how many comments have been posted. Someone once tried to explain me how but I don’t think I managed.
You can use this i guess after you apply your filter on comments of course.
$w.onReady( () => {
$w("#myDataset").onReady( () => {
let count = $w("#myDataset").getTotalCount();
So this gets the number of entries in the dataset (all comments combined ?)
and then ? how to display it ?
i don’t know how it works but try to put then. after your filter and put
“then.”
your filter {
}
then.
$w(" #myDataset “).onReady( () => {
let count = $w(” #myDataset ").getTotalCount();
i really don’t know
let filter = wixData.filter();
filter = filter
.eq("reference", $w("#input2").value);
then.
let count = $w("#myDataset").getTotalCount();
maybe? :)
and for the following
.then(res => {
$w('#yourcounter').text (or value for input label for button) = res.items;
});
maybe?
let filter = wixData.filter();
filter = filter
.eq("reference", $w("#input2").value);
let count = $w("#dataset2").getTotalCount();
.then(res => {
$w('#yourcounter').text (or value for input label for button) = res.items;
});
This should work IMO just add it seperately. This shouldn’t be related to your comment filtering.
can you please post the whole code, i am having a hard time following your codes.
Sure thing Amit !
Here is my code, the user can post a comment along with his username, and see other comments related to the current item. (dynamic page).
I’ve used the item’s ID (unique) and set an input (input2) to display that unique ID, so when someone posts a comment, it gets this unique ID and add it to a “reference” field in my “commentaires” (comments in French) database.
I’ve created 2 “commentaires” datasets, one in read only, to display comments in repeater5, and one on write only, to allow users to post a comment via a form.
$w("#dataset2").onReady( () => {
//CODE RELATED TO THE LIST OF COMMENTS
$w("#dataset2").onReady( () => {
//shows only item-related items via item's ID.
//reference = the field in the "commentaires database.
//input 2 = the input (read only) where the item's unique ID is displayed
//dataset2 = the "commentaires" read only dataset
let filter = wixData.filter();
filter = filter
.eq("reference", $w("#input2").value);
$w("#dataset2").setFilter(filter);
});
//CODE RELATED TO THE FORM TO POST A COMMENT
//post a comment and get the item's ID + title
//dataset3 = the "commentaires" write only dataset
$w("#dataset3").onReady( () => {
//this inserts the current item's 'ID' value in the dataset
$w('#dataset3').setFieldValue('reference', $w('#input2').value);
//this inserts the item's title in an 'item' field in the dataset
$w('#dataset3').setFieldValue('item', $w('#text54').text);
});
});
});
//______________
//refreshes comment supon submitting a comment then goes to top of comments
//once the user clicks on the button to submit a comment, it is submitted
//+ comments are refreshed + the user is automatically taken to the top of the
//list of comments
export function button39_click(event, $w) {
$w("#dataset2").refresh()
.then( () => {
$w('#anchor1').scrollTo();
});
}
Feel free to ask if you have any question (as far as I can answer :D)
Can you share your site so I can see it at work? Or is it still under construction?
What about the counter? Is it working i can’t see it in your codes
thank you so much, you have no idea how long i’ve been trying to create a comment box
and i was wondering why you named it commentaires, thanks for clearing that up.
hm … I’m not sure how to set up fields in the comments database. Can you help me out with this, please?
It is still under construction !
I haven’t mert, I will try to figure it out, now I’m trying to use the CKeditor to replace the ‘post comment’ box.
Jakub : what do you mean ? creating fields in a database ? You simply have to click on the ‘+’ sign on the top right, then name it as you wish.