I want to show/hide menu options on my page and I'm using the slideToggle to do this (in a with an ID called Additions .. at the bottom of the example .. However I don't want to use multiple functions for every set of menu options, I'd like to simplify this as much as possible .. as it is now I have one function, but it only affects the one set of options.
I'd like to be able to add the +/- to the other sets of options ..
The HTML
<div class="ttl-area">
<h2 class="ttl-account"><span>Account</span></h2>
</div>
<div class="account-area">
<div class="login-holder">
<p><strong>Welcome, <%= ViewModel.Profile.Name.First %></strong></p>
<ul class="account-links">
<span id="loginTitle">User Options</span><br /><br />
<li>
<%= Html.ActionLink<EventController>( x => x.List(), "All Events" )%>
</li>
<li>
<%= Html.ActionLink<MyEventsController>( x => x.List(), "My Events" )%>
</li>
<li>
<%= Html.ActionLink<AccountController>( x => x.Edit(), "My Profile" )%>
</li>
<li>
<%= Html.ActionLink<ClubController>( x => x.List(), "All Clubs" )%>
</li>
<li>
<%= Html.ActionLink<MyClubsController>( x => x.List(), "My Clubs" )%>
</li>
<li>
<%= Html.ActionLink<AccountController>( x => x.ChangePassword(), "Change My Password" )%>
</li>
<li>
<%= Html.ActionLink<DependantController>( x => x.List(), "My Dependants" ) %>
</li>
</ul>
</div>
<% if ( ViewModel.Profile.HasOrganizerInfo ) { %>
<div class="login-holder">
<ul class="account-links">
<span id="loginTitle">Organizer Details</span><br /><br />
<li>
<%= Html.ActionLink<AccountController>( x => x.Organizer(), "Organizer Details" )%>
</li>
<li>
<%= Html.ActionLink<EventController>( x => x.Edit( default(int?) ), "Post An Event" )%>
</li>
<li>
<%= Html.ActionLink<EventAdminController>( x => x.List(), "Events Created By Me" ) %>
</li>
<li>
<%= Html.ActionLink<ClubController>( x => x.Edit( default( int? ) ), "Create A Club" )%>
</li>
<li>
<%= Html.ActionLink<ClubAdminController>( x => x.List( ), "Clubs Created By Me" )%>
</li>
<% if ( ViewModel.Roles.Select(x => x.Name == "Administrator").Count() > 0 ) { %>
<li>
<%= Html.ActionLink<EventReportController>( x => x.List(), "Event Report" ) %>
</li>
<% } %>
</ul>
</div>
<% } %>
<% if ( ViewModel.Profile.HasTimerInfo ) { %>
<div class="login-holder">
<ul class="account-links">
<span id="loginTitle">Timer Details</span><br /><br />
<li>
<%= Html.ActionLink<AccountController>( x => x.Timer(), "Timer Details" )%>
</li>
<li>
<%= Html.ActionLink<EventTimerController>( x => x.List(), "Events Timed By Me" ) %>
</li>
</ul>
</div>
<% } %>
<ul class="account-links">
<% if ( ( !ViewModel.Profile.HasOrganizerInfo ) || ( !ViewModel.Profile.HasTimerInfo) ) { %>
<span id="loginTitle">Additional Options<span id="toggle" style="margin-left: 30px; padding-right: 10px;">-</span></span><br /><br />
<div id="additions">
<% } %>
<% if ( !ViewModel.Profile.HasTimerInfo ) { %>
<li>
<%= Html.ActionLink<AccountController>( x => x.Timer(), "I Time Events" )%>
</li>
<% } %>
<% if ( !ViewModel.Profile.HasOrganizerInfo ) { %>
<li>
<%= Html.ActionLink<AccountController>( x => x.Organizer(), "I Organize Events" )%>
</li>
<% } %>
<li><%= Html.ActionLink<AccountController>( x => x.Logout(), "Log Out" ) %></li>
</div>
</ul>
</div>
The Script
<script type="text/javascript">
$(document).ready(function() {
$("#toggle").click(function() {
$("#additions").slideToggle("slow");
if ($("#toggle").html() == "+") {
$("#toggle").html("-");
} else {
$("#toggle").html("+");
}
});
})
</script>