快速进入代码,下面是手风琴的asp.net标记,主题标题为每个窗格的标题,其内容是要审核的评论。
<ajaxToolkit:Accordion runat="server" id="accCommentTrash" fadetransitions="true"
selectedindex="-1" requireopenedpane="false" autosize="None" headercssclass="accTitle"
headerselectedcssclass="accSelectedTitle">
<HeaderTemplate>
<h4>
Title:(<%# ((System.Data.DataRowView)Container.DataItem)["Title"]%>)</h4>
</HeaderTemplate>
<ContentTemplate>
<asp:Repeater runat="server" id="rptrComments" datasource='<%# ((System.Data.DataRowView)Container.DataItem).CreateChildView("CommentRelation") %>'>
<HeaderTemplate>
<ul class="comment_trash">
</HeaderTemplate>
<ItemTemplate>
<li id='<%# new Utilities().encrypt(((System.Data.DataRowView)Container.DataItem)["CommentId"].ToString()) %>'
name='<%# new Utilities().encrypt(((System.Data.DataRowView)Container.DataItem)["CommentId"].ToString()) %>'>
<asp:Label id="lblCommentor" runat="server" text='<%# ((System.Data.DataRowView)Container.DataItem)["AuthorName"] %>'
cssclass=""></asp:Label>
<span>Commented on </span><a href='?id=<%# new Utilities().encrypt(((System.Data.DataRowView)Container.DataItem)["BoardId"].ToString())%>'
title="Click to view board" class="">
<%# ((System.Data.DataRowView)Container.DataItem)["Title"] %>
</a>
<p>
<asp:Label runat="server" id="lblComment" text='<%# ((System.Data.DataRowView)Container.DataItem)["Comment"] %>'
cssclass=""></asp:Label>
</p>
<p>
Trashed about
<%# GetTimeSpan(DateTime.Now,((System.Data.DataRowView)Container.DataItem)["ModifiedOn"].ToString()) %>
hours ago, Commented on
<%# DateTime.Parse(((System.Data.DataRowView)Container.DataItem)["CreatedOn"].ToString()).ToLongDateString() %>
</p>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</ajaxToolkit:Accordion>
及以下是我附加到列表项的javascript事件,列表项显示要审核的注释。只需单击鼠标上的单击事件,鼠标悬停和鼠标移除就不再有效了。
//comment restore
if ($get("<%= accCommentTrash.ClientID%>")) {
var li = $get("<%= accCommentTrash.ClientID%>").getElementsByTagName("li");
console.log(li);
for (iloopCounter = 0; iloopCounter < li.length; iloopCounter++) {
$addHandlers(li[iloopCounter], {
mouseover: ul_li_hover,
mouseout: ul_li_hover
});
$addHandler(li[iloopCounter],"click",restoreComment);
}
}
下面是恢复评论功能,
function restoreComment(evnt){
console.log(this.name);
console.log(this.id);
}
现在,我在做错了什么。 Firebug向我展示了事件列表,但事件并未触发:(
答案 0 :(得分:0)
这是因为Accordian在发生方法时通过调用event.preventDefault
来防止事件发生。我将控制权改为转发器并解决了它