I have a repeater, anchor tag and div tag inside it. The anchor has a jquery which is doing slidetoggle. But for example if I have 5 items in repeater div count is also 5 and when I click the anchor all divs are doing slidetoggle.
If I use itemcommand it’s ok, but this time js is not working. Because I’m using linkbutton and it has no click event as you know. So is there any solution to fix it?
Here is my repeater and js.
<head runat="server">
<title></title>
<script src="jquery-1.8.4.js"></script>
<script src="jquery-ui-1.9.2.custom.js"></script>
<script src="jquery-ui-1.9.2.custom.min.js"></script>
<script>
$(function () {
$('[id*=aNotice]').click(function () {
$('[id*=dvContent]').slideToggle(400);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="rptNotice" runat="server">
<ItemTemplate>
<a id="aNotice" runat="server">click to see toggle</a>
<div id="dvContent" runat="server"><%#Eval("content") %></div>
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
You can use
nextmethod:Note that IDs must be unique and using
$('[id*=aNotice]')is overkill, you should use classes instead.And also there is need to load jQuery UI twice,
jquery-ui-1.9.2.custom.min.jsis just minified version ofjquery-ui-1.9.2.custom.js.