Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've implemented this in my application.</p> <p><img src="https://i.stack.imgur.com/3Gs46.png" alt="enter image description here"></p> <p>I'm not sure what to tell you though. It's easier when we have an attempted solution to fix.</p> <p>Here's an overview of how mine works:</p> <ul> <li>I have created a controller called <strong>SharedController</strong>. The purpose of it is to contain various actions that render common actions. All of the actions are considered <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.childactiononlyattribute(v=vs.118).aspx" rel="nofollow noreferrer">ChildActionOnly</a>.</li> <li>My <strong>_Layout</strong> uses <a href="http://msdn.microsoft.com/en-us/library/ee703541(v=vs.118).aspx" rel="nofollow noreferrer">RenderAction</a> to render the action <strong>NavbarPartial</strong> which is in my SharedController.</li> <li>More importantly the Navbar partial then uses RenderAction to render the action <strong>ThemeListPartial</strong>. This action is responsible for getting a list of available themes. The list of available themes is determined at applications startup. I've created a <em>ThemeFinder</em> class and <em>ThemeRepository</em> class that are responsible for finding and storing themes. The ThemeFinder finds themes by expressions that you give it. In a new class called App_Start/ThemeConfig I've given it only one expression - "~/Content/themes/{name}.bootstrap.css". This will find all themes with that naming convention in that location.</li> <li>My razor code will take the <a href="https://stackoverflow.com/questions/11064316/what-is-viewmodel-in-mvc">ViewModel</a> and display a <a href="http://getbootstrap.com/components/#navbar" rel="nofollow noreferrer">dropdown menu in the navbar</a>.</li> <li>To get the themes to change my dropdown menu contains an <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.actionlink(v=vs.118).aspx" rel="nofollow noreferrer">AJAX link</a> to an action called <strong>SaveTheme</strong> in <strong>ThemeController</strong>. This action takes a theme name as a string and tries to save it in a cookie for the user.</li> <li>If the theme is found and saved successfully, the action responds with a success message.</li> <li>jQuery then changes the theme by finding the associated <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link" rel="nofollow noreferrer">link attribute</a> and changing the HREF contents to the new theme. It knows the new theme relative URL because I have it stored in <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data" rel="nofollow noreferrer">data attributes</a>.</li> </ul> <p>I completed this before I made the switch to <a href="http://angularjs.org/" rel="nofollow noreferrer">AngularJs</a>. The one thing I plan to go back and change is to cut out as much (maybe all) jQuery as possible and replace it with better code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload