Web ページの左側にカテゴリのリストがあり、右側にアイテムのリストがあります。アイテムのリストには cat という属性があり、値は数値です。
カテゴリをクリックすると、同じカテゴリ ID を持つ最初の項目にスクロールする必要があります。
任意のヒント?:)
html は次のとおりです。
asp:Repeater runat="server" ID="repCategory" OnItemDataBound="CategoryItemRepeater">
<HeaderTemplate>
<ul class="menuListUl">
</HeaderTemplate>
<ItemTemplate>
<li>
<div id="catItem" runat="server"></div>
</li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
<div id="menuList">
<asp:Repeater runat="server" ID="repFooditems" OnItemDataBound="MenuItemRepeater">
<ItemTemplate>
<div class="menuItem" id="menuItem" runat="server">
<div runat="server" class="itemNumber" id="ItemId"></div>
<div runat="server" class="itemName" id="itemName"></div>
<div runat="server" class="itemDescription" id="itemDescriptionLbl"></div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
コードビハインド:
カテゴリリスト:
var lbl = (HtmlGenericControl)e.Item.FindControl("catItem");
lbl.Attributes.Add("catId",""+rest.CategoryId);
アイテムリスト:
var menuItem = (HtmlGenericControl)e.Item.FindControl("menuItem");
menuItem.Attributes.Add ("cat","cat"+item.Item.Category.FirstOrDefault().CategoryId);
jquery:
$('.menuListUl li div').bind('click', function ()
{
var catId = $(this).attr('catid'); //The categoryid on the element clicked.
// Now: find the first element with the same cat id
var element = ""; The element found.
$('html, body').animate({
scrollTop: element.offset().top
}, 2000);
});