1.0.1 • Published 6 years ago

directify v1.0.1

Weekly downloads
23
License
BSD
Repository
github
Last release
6 years ago

Directify

Directify is a client-side router, actually it's pretty much Director.js (included) with some additional features/tweaks.

npm install directify

Example usage:

var router = require('directify');

// Usage: router(routingTable, targetElement, directorOpts);

var directorOpts = {
  notfound: function () {
    console.error('route not found')
  }
}

var routingTable = {
  '/': function() {
    return this.target.innerHTML = 'This is the root url.';
  },

  '/systems': function() {
    return this.target.innerHTML = "This is another path, it is: " + this.path;
  },

  '/parent': {
    '/sub/:json': function() {
      return this.target.innerHTML = "This path takes json params, they are: " + (JSON.stringify(this.params));
    }
  }
};

$(document).ready(function() {
  var targetElement = document.getElementById('main');
  router(routingTable, targetElement, directorOpts);
});
1.0.1

6 years ago

1.0.0

6 years ago

0.2.0

7 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.0

11 years ago