UNPKG

marbles

Version:

Front-end framework for routing, http, and data handling

192 lines (81 loc) 3.86 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Router</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Router</h1> <section> <header> <h2> <span class="ancestors"><a href="Marbles.html">Marbles</a>.</span> Router </h2> </header> <article> <div class="container-overview"> <dt> <h4 class="name" id="Router"><span class="type-signature"></span>new Router<span class="signature">()</span><span class="type-signature"></span></h4> </dt> <dd> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="marbles.js.html">marbles.js</a>, <a href="marbles.js.html#line1507">line 1507</a> </li></ul></dd> <dt class="tag-see">See:</dt> <dd class="tag-see"> <ul> <li><a href="Marbles.History.html">Marbles.History</a></li> </ul> </dd> </dl> <h5>Example</h5> <pre class="prettyprint"><code>var MyRouter = Marbles.Router.createClass({ displayName: "MyRouter", // routes are evaluated in the order they are defined routes: [ { path: "posts", handler: "posts" }, // :id will be available in the params { path: "posts/:id", handler: "posts" }, // * will be available in the params as `splat` { path: "posts/:id/*", handler: "posts" }, ], beforeHandler: function (event) { // optional before hook // same as handler:before event sent through dispatcher // but only called for the router the handler belongs to // and called before event is sent through dispatcher }, posts: function (params, opts) { // params is an array of objects, // params[0] should be all you need unless // you have multiple params of the same name // opts contains any extra properties given in a route object } }); new MyRouter(); // bring it to life</code></pre> </dd> </div> </article> </section> </div> <nav> <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Marbles.Collection.html">Collection</a></li><li><a href="Marbles.History.html">History</a></li><li><a href="Marbles.HTTPRequest.html">HTTPRequest</a></li><li><a href="Marbles.Model.html">Model</a></li><li><a href="Marbles.Object.html">Object</a></li><li><a href="Marbles.Router.html">Router</a></li><li><a href="Marbles.Store.html">Store</a></li></ul><h3>Namespaces</h3><ul><li><a href="Marbles.html">Marbles</a></li><li><a href="Marbles.HTTP.Middleware.html">Middleware</a></li><li><a href="Marbles.Utils.html">Utils</a></li></ul><h3>Mixins</h3><ul><li><a href="Marbles.Accessors.html">Accessors</a></li><li><a href="Marbles.Dispatcher.html">Dispatcher</a></li><li><a href="Marbles.Events.html">Events</a></li><li><a href="Marbles.HTTP.LinkHeader.html">LinkHeader</a></li><li><a href="Marbles.QueryParams.html">QueryParams</a></li><li><a href="Marbles.State.html">State</a></li></ul> </nav> <br clear="both"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Fri Jan 09 2015 21:26:15 GMT-0500 (EST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>