From: Zach Copley Date: Sat, 16 Apr 2011 02:50:05 +0000 (-0700) Subject: Getting some traction here on better QnA Ajax X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d1443a6bd9e005d8944c3b92b56a41c644b6f19f;p=quix0rs-gnu-social.git Getting some traction here on better QnA Ajax --- diff --git a/js/util.js b/js/util.js index 2cb370ef5f..811e124086 100644 --- a/js/util.js +++ b/js/util.js @@ -428,6 +428,7 @@ var SN = { // StatusNet var id = $(notice).attr('id'); if ($("#"+id).length == 0) { + console.log("inserting before placeholder"); $(notice).insertBefore(placeholder); } else { // Realtime came through before us... diff --git a/plugins/QnA/js/qna.js b/plugins/QnA/js/qna.js index c83440452f..c7add55ca6 100644 --- a/plugins/QnA/js/qna.js +++ b/plugins/QnA/js/qna.js @@ -32,46 +32,42 @@ var QnA = { * @param {jQuery} notice: jQuery object containing one notice */ NoticeInlineAnswerTrigger: function(notice) { - console.log('NoticeInlineAnswerTrigger - begin'); - - // Find the question notice we're answering... + // Find the notice we're replying to... var id = $($('.notice_id', notice)[0]).text(); - console.log("parent notice id = " + id); - var parentNotice = notice; - - // See if the form's already there... - var answerForm = $('#answer-form', parentNotice); - - if (answerForm) { - console.log("Found the answer form."); - } else { - console.log("Did not find the answer form."); - } - var placeholder = parentNotice.find('li.notice-answer-placeholder'); + console.log("NoticeInlineAnswerTrigger - replying to notice " + id); - // Pull the parents threaded list and we'll add on the end of it. - var list = $('ul.threaded-replies', notice); + var parentNotice = notice; - if (list) { - console.log("Found the " + list.length + " notice place holders."); + // Find the threaded replies view we'll be adding to... + var list = notice.closest('.notices'); + if (list.hasClass('threaded-replies')) { + console.log("NoticeInlineAnswerTrigger - there's already a threaded-replies ul above me"); + // We're replying to a reply; use reply form on the end of this list. + // We'll add our form at the end of this; grab the root notice. + parentNotice = list.closest('.notice'); + console.log("NoticeInlineAnswerTrigger - trying to find the closed .notice above me"); + if (parentNotice.length > 0) { + console.log("NoticeInlineAnswerTrigger - found that closest .notice"); + } } else { - console.log("Found the notice answer placeholder"); - } - - if (list.length == 0) { - console.log("list length = 0 adding