diff --git a/forum/forms.py b/forum/forms.py index ec1d2ff..fc216ed 100644 --- a/forum/forms.py +++ b/forum/forms.py @@ -41,10 +41,11 @@ class PostAnswerForm(forms.ModelForm): class Meta: model = PostAnswer - fields = ('message', ) + fields = ('message', 'post', ) labels = { 'message': _('Message') } widgets = { 'message': forms.Textarea(attrs={'cols': 80, 'rows': 3}), + 'post': forms.HiddenInput(), } \ No newline at end of file diff --git a/forum/static/js/forum.js b/forum/static/js/forum.js index 51d0069..0ccd594 100644 --- a/forum/static/js/forum.js +++ b/forum/static/js/forum.js @@ -217,6 +217,26 @@ function answer(id, url) { url: url, success: function(data) { $("#post_"+id).find(".answer_post").html(data); + $("#post_"+id).find("#id_post").val(id); + + var frm = $("#post_"+id).find(".answer_post_form"); + frm.submit(function () { + $.ajax({ + type: frm.attr('method'), + url: frm.attr('action'), + data: frm.serialize(), + success: function (data) { + $("#post_"+id).find(".answer_list").append(data); + + $("#post_"+id).find(".answer_post").hide(); + }, + error: function(data) { + console.log(frm.serialize()); + console.log('Error'); + } + }); + return false; + }); } }); diff --git a/forum/templates/post/post_list.html b/forum/templates/post/post_list.html index a2d51d9..5d3073a 100644 --- a/forum/templates/post/post_list.html +++ b/forum/templates/post/post_list.html @@ -36,8 +36,10 @@
{{ post.message|linebreaks }}
+