title: How to redirect to another page after Knockout click event
body: <p>Each page in a multi-page site displays a logout link and binds to a view model that implements authentication functionality and state. Here is a simplification:</p>
  
  <pre><code>&lt;a href="#" data-bind="click: logout"&gt;Logout&lt;/a&gt;
  ...
  function ViewModel() {
      var self = this;
      self.authenticated = ko.observable(true);                
      self.logout = function () {            
          self.authenticated(false);
      };
  };
  </code></pre>
  
  <p>Upon logout, I want to redirect back to the site's login page. I know I can do it in the logout function:</p>
  
  <pre><code>self.logout = function () {
      self.authenticated(false);
      window.location.href = "login.html";
  };
  </code></pre>
  
  <p>But to maintain a cleaner separation between view and view model, I would rather the view respond to change in the authenticated property of the view model. I envision something like this, though this example does not work - the script block is not hidden and consequently the redirect always occurs:</p>
  
  <pre><code>&lt;div data-bind="ifnot: authenticated()"&gt;&lt;script&gt;alert("window.location.href = 'login.html';");&lt;/script&gt;&lt;/div&gt;
  </code></pre>
  
  <p>So, how do we redirect here in an MVVM manner? I appreciate everyone's assistance; Knockout is a fantastic library.</p>