EDIT: Solved this in a better way, my way below was stupid. I now just make a clone of the existing reply form on the page and set the value for the hidden input named "parent" to the correct number and it works fine.
Still would like to know why the form loaded twice in my original code below, but not important.
------
Hi there all web dev experts!
This is a jQuery question, but as usual I only trust Modx people so I ask here instead of in the jQuery forums.
I’m a jQuery beginner so this should probably be easy to answer...
I’m trying to load the Quip reply form into the page where the comments are. This is for when someone answers to some comment already made by someone other, threaded reply. I need to display the reply form just under the existing comment in the middle of the comment tree.
I have the separate quip answer page setup as usual:
[[!Quip? &somestuffhere=``]]
[[!QuipReply]]
Everything is working as it should without the ajax part.
To load the reply form into the page where the comments are I use this js code:
$(".quip-reply-link a").click(function(){
//Find out what div to insert reply form after:
thisdiv = $(this).closest('.quip-comment-body');
// Create a new div to insert:
newdiv = $('<div id="newdiv">Load the reply form into this div</div>');
// Insert the div:
thisdiv.after(newdiv);
// Load the reply form into the new div (hardcoded "get" data for testing):
newdiv.load('http://www.mysite.com/quipreply.html?quip_thread=cmt2438&quip_parent=7298 #quip-reply-form');
return false;
});
The form is loadning fine, but: It loads twice! I get two identical reply forms in the new div.
Would be nice if someone could tell me what I’m doing wrong...
Also, if someone have a suggestion of doing this in a better way, it would be nice too. Perhaps I just should load a reply form and set the correct post url without using the separate quip reply page?
Even if so, still would like to know why the form is loading twice, need to get better with jQuery...
Thanks!