回复和评论的动态添加

views.py

t = get_template('reply_item.html')
html = t.render(template.Context({'i':answer,'user':user}))
ret={'status':'succeed','error':answer.id,'html':html}

js

                            $("#ask_table").append(data.html);

html

<tr >
<td align="left" width="65px" valign="top" style="padding:10px 0px 0px 10px;">
<a href="/profile/profileview/{{ i.user.get_profile.id }}">
<img class="smallImage imgborder" src="/site_media/{{ i.user.get_profile.profile_picture }}"/></a>
<span style="display:block; margin:10px 0px 0px 0px; "><a class="smallA" href="/profile/profileview/{{ i.user.id }}">{{i.user}}</a></span>
<span style="display:block; margin:10px 0px 0px 0px;">Title</span>
<span style="display:block; margin:10px 0px 0px 0px;">{{i.time|date:"F,j,Y"}}</span></td>
<td valign="top" width="50px">
{%if not question.is_solve%}
{%ifequal question.user user%}
<a class="makedeal" id="makedeal{{ i.id }}" data="ask_makedeal">Deal</a></td>
{%endifequal%}

{% else %}
{% if i.is_succeed %}
<a class="imageA" id="makedeal{{ i.id }}" data="ask_makedeal">
<img style="margin:20px 0px 0px 0px;" src="/site_media/photos/solved.gif"/></a></td>
{% endif %}
{%endif%}

<td width="600px" valign="top">
<p class="contentP">{{i.content}}
{% ifequal i.user user %}
<a class="change_answer smallA"><i>edit</i></a>
{% endifequal %}

</p>
{% ifequal i.user user %}
{% endifequal %}
<p align="left">{% if i.attach %}
<span><strong>Attachment:</strong><a class="smallA preview" id="answer_attach" href="/site_media/{{i.attach}}">{{i.attach}}</a></span>
{% endif %}</p>
<span style="float:right;">
<a id="ask_disagree_{{ i.id }}" class="button1 button18 width150" num="{{ i.dislike_number }}" data="ask_disagree">
<img src="/site_static/images/disagree.png"> DisAgree| <span class="fontgray">{{ i.dislike_number }}</span></a>
</span>
<span style="float:right;"><a id="ask_agree_{{ i.id }}" class="button1 button18 width130" num="{{ i.like_number }}" data="ask_agree">
<img src="/site_static/images/agree.png"> Agree| <span class="fontgray">{{ i.like_number }}</span></a>
</span>
<span style="float:right;"><a id="ask_comment_{{ i.id }}" class="button1 button18 width100" num="{{ i.comment_count }}" data="ask_comment">
<img src="/site_static/images/reply1.png"> Reply | <span class="fontgray">{{ i.comment_count }}</span></a></span>
<form id="comment_{{ i.id }}_form" action="/questions/add_comment/{{ i.id }}" method="post">
<div id="relpyP_{{ i.id }}" class="replyP">
<div id="commentD_{{ i.id }}"></div>
<textarea id="textarea_{{ i.id }}" name="content" class="text textarea1" rows="" cols=""></textarea>
<input id="comment_{{ i.id }}" type="button" class="button1 button11" value="post" data="comment_post">

</div></form>
</td>
</tr>

原文地址:https://www.cnblogs.com/lddhbu/p/2675965.html