director
Router type
Client-side routing (aka hash-routing) allows you to specify some information about the state of the application using the URL. So that when the user visits a specific URL, the application can be transformed accordingly.
Example
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>A Gentle Introduction</title>
    <script src="https://raw.github.com/flatiron/director/master/build/director.min.js"></script>
    <script>

      var author = function () { console.log("author"); },
          books = function () { console.log("books"); },
          viewBook = function(bookId) { console.log("viewBook: bookId is populated: " + bookId); };

      var routes = {
        '/author': author,
        '/books': [books, function() { console.log("An inline route handler."); }],
        '/books/view/:bookId': viewBook
      };

      var router = Router(routes);
      router.init();

    </script>
  </head>
  <body>
    <ul>
      <li><a href="#/author">#/author</a></li>
      <li><a href="#/books">#/books</a></li>
      <li><a href="#/books/view/1">#/books/view/1</a></li>
    </ul>
  </body>
</html>
Inheritance Hierarchy

Object
   Router

Browser Compatibility
8
5
5
Fields
 NameDescription
public Fieldasync  
public Fielddelimiter  
public Fieldevery  
public Fieldhistory  
public FieldhistorySupport  
public Fieldmethods  
public Fieldnotfound  
public Fieldparams  
public Fieldrecurse  
public Fieldresource  
public Fieldroutes  
public Fieldrun_in_init  
public Fieldscope  
public Fieldstrict  
Top
Methods
 NameDescription
public MethodconfigureGiven the flexible nature of director there are several options available for both the Client-side and Server-side. These options can be set using the .configure() method  
public MethoddispatchDispatches the route handlers matched within the Routing Table for this instance for the specified method and path.  
public MethodgetRouteReturns the entire route or just a section of it.  
public MethodinitInitialize the router, start listening for changes to the URL.  
public MethodinsertExinsert a callback that will only occur once per the matched route.  
public MethodmountInserts the partial Routing Table, routes, into the Routing Table for this Router instance at the specified path.  
public MethodonAdds the route handler for the specified method and path within the Routing Table.  
public MethodparamAdds a route fragment for the given string token to the specified regex matcher to this Router instance. See URL Parameters for more documentation.  
public MethodsetRouteRemove a segment from the current route.  
Top
See Also

Reference

(Global) Namespace

 

 


© 2013 All Rights Reserved.

Send comments on this topic.