Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'parent' #41

Open
hrmshandy opened this issue Feb 24, 2016 · 13 comments
Open

Cannot read property 'parent' #41

hrmshandy opened this issue Feb 24, 2016 · 13 comments
Labels

Comments

@hrmshandy
Copy link

Hello,
I have a problem, if i use ajax in getComments always appears error Cannot read property 'parent', can you help me?

Thank you.

@jjtykkyl
Copy link
Contributor

Can you paste a code example or (preferably) a link to a CodePen demonstrating the issue so that I could dig into the problem more deeply?

@hrmshandy
Copy link
Author

You can check this url http://codepen.io/shandy05/pen/EPqeGm, try to reply and reload

@jjtykkyl
Copy link
Contributor

There was a bug indeed when comparing the dates of two comments, this is now fixed in the newest version 1.1.1. The fix was done in: 5a0b13a

@hrmshandy
Copy link
Author

still not working :(

@jjtykkyl
Copy link
Contributor

Now I got it working in codepen after 5d5bed4. Still, I don't understand why it works after this commit, I think there are some issues in your data. For example, there may be a parent comment that has a timestamp later than one of its replies

@hrmshandy
Copy link
Author

ok, thanks for help

@jjtykkyl
Copy link
Contributor

Did you get it working after the latest commit?

@hrmshandy
Copy link
Author

sometimes working, I don't know where is problem

@jjtykkyl
Copy link
Contributor

Unfortunately I don't have time to investigate this issue right now but you can do so if you will. The problem is in sorting the comments at the beginning, line 635:

                comments.sort(function(commentA, commentB) {
                    var createdA = new Date(commentA.created).getTime();
                    var createdB = new Date(commentB.created).getTime();
                    if(sortKey == 'oldest') {
                        return createdB - createdA < 0;
                    } else {
                        return createdB - createdA > 0;
                    }
                });

For some reason the comments are not sorted by date and thus the parent of a certain comment cannot be referenced in the commentsById dictionary.

@hrmshandy
Copy link
Author

ok, i will try to investigate, thanks jjtykkyl :)

@jjtykkyl jjtykkyl added the bug label Jul 4, 2016
@baimurzin
Copy link

I found the same bug on my own project. Also i figured out that my mistake was I got some comments from server without date and this was the reason, because comments firstly sorted on line 272:
// Sort comments by date (oldest first so that they can be appended to the data model

I removed all comments without date and it works

@KG20
Copy link

KG20 commented Oct 13, 2016

Hello, was this problem resolved? Because i tried everything suggested above, and the problem is still coming. I noticed that when i add more than a certain amount of data.. i deleted all the data and tried again, the same problem..I amended the comments-data.js and added one more comment, and it gives the same problem, can that more than 10 comments causes problems or am I doing something wrong? Thanks!

@craake
Copy link

craake commented Aug 21, 2017

Hi everybody! It's been a while since last post here, but I might have a good news for those who still struggle with this strange bug or will in the future. A bit of a workaround...

When implementing this plugin, make sure to have timeFormatter() function added to your config. It must return time format that include time along date (e.g. G:i M, d Y). That is the only way to have proper loading order of comments, and to avoid missing parent for comment replies.

Hope this will help someone.

adanski pushed a commit to adanski/ax-comments that referenced this issue Dec 18, 2022
adanski pushed a commit to adanski/ax-comments that referenced this issue Dec 18, 2022
adanski pushed a commit to adanski/ax-comments that referenced this issue Dec 21, 2022
adanski pushed a commit to adanski/ax-comments that referenced this issue Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants