【发布时间】:2011-09-22 04:28:17
【问题描述】:
我正在构建一个公告板系统,我们可以向其发布消息,人们可以回复消息。我发布了一条新消息工作正常,对于每条新消息,我使用 AJAX 为每条消息创建一个新的表格行:
<table id="content-table">
<tr>
<th scope="col" class="messagetime"> <? echo $time; ?> </th>
<th scope="col" class"message body"></th>
<th scope="col" class="messagereply"><form method="GET" action="Rindex.php"><input name="id" type="hidden" value="<? echo $id; ?>"><button type="submit" style="border-style:none;" class="post-icon" /></form></th>
</tr>
</table>
在最后一列中,我有一张他们按下的图像,我希望 jQuery 在该行下方创建一个新表格行,其中包含用于输入回复消息的字段,该回复消息将发布到该特定消息。
我目前可以为每条消息获取一个新行并隐藏/显示所有消息,但我无法弄清楚如何让回复按钮定位到唯一行来回复消息:
<table id="content-table">
<tr>
<th scope="col" class="messagetime"> <? echo $time; ?> </th>
<th scope="col" class"message body"></th>
<th scope="col" class="messagereply"><form method="GET" action="Rindex.php"><input name="id" type="hidden" value="<? echo $id; ?>"><button type="submit" style="border-style:none;" class="post-icon" /></form></th>
</tr>
<tr id="replyrow" class="replyrow">
<th scope="col"></th>
<th scope="col" class="replyrowcontent"> <Post Reply Form would be in here.> </th>
<th scope="col"></th>
</tr>
</table>
有什么建议吗?我有一种感觉会涉及到父母/孩子的关系,但我在脑海中概念化了这一点!
【问题讨论】:
-
我的建议是不要使用表格进行布局。
-
有什么建议吗?你知道这很有趣。看看 stackoverflow 如何有一个隐藏的 DIV 来显示您何时想要回复消息?我正在尝试这样的事情......
标签: jquery ajax html-table row toggle