ここで助けを求める前に、私の問題と、それを修正しようとして何をしたかをできる限り正確に説明しようと思います. 私が使用しているスクリプトは、ajax を介して新しいコメントを追加します。それは機能しますが、他のスクリプトと同様に..問題があります。私のウェブサイトでは、newst コメントを最初に表示するように設定しました。
そのため、最初のコメントが投稿されました - 上部に追加されました。
投稿された 2 番目のコメント (ページを更新せずに) は、最初のコメントの上に追加する必要があります。代わりに、最初のコメントの下に追加します。このように、3 番目は 2 番目の下に、4 番目は 3 番目の下に投稿されます...
http://s8.postimg.org/407uhljl1/image.jpg
これは魔法が起こる場所です http://pastebin.com/5nFeEpZg
より正確にここにいる:
var the_parent_class = jQuery('#'+css_respond).parent().attr('class');
if(typeof the_parent_class != "undefined" && the_parent_class.search(/depth-/i)
!= -1) { //threaded
// Check if there are already replies, if not, add <ul class="children">
if(jQuery('#'+css_respond).parent().children('.children').length) {
// There are replies, add comment to the end of the list
jQuery('#'+css_respond).parent().children('.children').append(tmpComment);
} else {
// First reply
tmpComment = '<ul class="children">'+tmpComment+'</ul>';
jQuery('#'+css_respond).parent().append(tmpComment) }
else
{
// Normal comment
if(commentPosition == 'bottom') {
jQuery('.'+css_commentlist).append(tmpComment);
}
else if(commentPosition == 'top')
{
jQuery('.'+css_commentlist).prepend(tmpComment);
}
else {
jQuery('.'+css_commentlist).append(tmpComment);
}
}
}
else {
// The commentlist doesn't exist, this is the first comment
// Do we need to support the 'Content Press' Theme?
if(compatContentPress == 'checked') {
jQuery('div.postbox').before(jQuery(tmpComment).find('div.boxcomments'));
} else {
tmpComment = '<ol class="'+css_commentlist+'">'+tmpComment+'</ol>';
jQuery('#'+css_respond).before(jQuery(tmpComment));
}
}
ページが更新されると、コメントが本来のように表示されます-最新の投稿が最初に表示されます-したがって、問題はコメントの追加にあるはずです。
ここで質問する前に、ブレークポイントを設定しようとしました
var the_parent_class = jQuery('#' + css_respond).parent().attr('class');
同時に、commentPosition を「下」から「上」に、上から下に切り替えましたが、何も変わりませんでした。
このスクリプトは PTM Ajax Comments と呼ばれ、github リポジトリからダウンロードしました。
commentPosition = data.commentPosition;
commentPosition = data.commentPosition;
if(commentPosition == 'bottom') {
} else if(commentPosition == 'top') {