In my master page I have a menu that uses jquery ui accordion.
What is the best way to specify which item should be active?? the only thing I can think of is
$(document).ready(function() {
$("#accordion").accordion({
collapsible: true,
autoHeight: false,
active:<%=ViewData["active"] %>
});
})
But it seems a little repetitive having to set ViewData[“active”] everytime a View is called throughout my whole app… what do you think?
Have you considered putting the accordian in a PartialView? Then you place your code within the PartialView and away from the Master page.
Also you can have a base controller which can set the ViewData for you so now it’s in one place.
Edit
It’s the same as any other base class. Your controller inherits from
Controllerso your base class will need to do the same;Now set your controller class to inherit from the ControllerBase class;
I’ve also implemented a CacheHelper but you can obviously use your own flavour of storing the current value.