How to use the mithril.route function in mithril

To help you get started, we’ve selected a few mithril examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArthurClemens / polythene / packages / examples / src / index.js View on Github external
app.controller = () => {
    m.redraw.strategy('diff');
    // use flexible routing to support nested route calls (f.i. in the dialog and tabs examples)
    const route = getRouteBase(m.route());
    const link = linkMap[route];
    app.vm.module(getNewModule(link));
    const linkName = link && link.name ? link.name : 'index';
    app.vm.moduleName = linkName;
    const baseTitle = 'Polythene Examples';
    document.title = linkName ? (baseTitle + ': ' + linkName) : baseTitle;
};
github jsguy / misojs / client / croutes.js View on Github external
*/
var m = require('mithril'),
	sugartags = require('../server/mithril.sugartags.node.js')(m),
	bindings = require('../server/mithril.bindings.node.js')(m),
	store = require('../server/store.js'),
	//getParam = require('../server/get')
	home = require('../c/home'),
	user = require('../c/user');

//	Expose to window
// if(typeof window !== "undefined") {
// 	window.m = m;
// }

m.route.mode = "pathname";
m.route(document.body, '/', {
	"/": {
		controller: home.home,
		view: function(ctrl){
			with(sugartags) {
			return 	DIV({ hover: [ctrl.set(ctrl.rotate, 225), ctrl.set(ctrl.rotate, 0)] }, [
					DIV('Hello ', ctrl.name, { rotate: ctrl.rotate }),
					A({ href: '/user/1', config: m.route}, "User")
				])
			} 
		}
	},
	"/user/:user_id":{
		controller: user.edit,
		view: function(ctrl){
			with(sugartags) {
				return DIV('Hello ' + ctrl.user.name + '! Server: ' + ctrl.isServer)
github tivac / crucible / src / lib / require-auth.js View on Github external
controller : function() {
            /* eslint consistent-return: 0 */
            if(config.auth && !valid()) {
                return m.route(prefix("/login") + window.location.search);
            }
        },
github eiriksm / kyll-thrill / js / src / index.js View on Github external
setTimeout(function() {
          m.route(u);
        }, 10);
      }
github ArthurClemens / mithril-page-slider / lib / mithril-page-slider.es6 View on Github external
const slide = (opts) => {
    const sliderId = opts.slider || DEFAULT_SLIDER_ID;
    const vm = getViewModel(sliderId);
    if (vm.hasTransition()) {
        return;
    }

    const route = opts.route || m.route();
    const id = opts.id || route;
    const currentId = vm.currentId();

    if (currentId !== undefined && currentId === id && vm.current()) {
        return;
    }
    const transition = {
        page: opts.page,
        id: id,
        route: route,
        done: opts.done,
        direction: opts.direction || DIRECTION_FORWARD,
        duration: opts.duration || DEFAULT_DURATION
    };
    vm.orientation(opts.rtl ? RTL_ORIENTATION : DEFAULT_ORIENTATION);
    if (!vm.current()) {
github tivac / crucible / src / pages / listing / index.js View on Github external
ctrl.add = function() {
        var result;

        result = db.child("content/" + ctrl.schema.key).push({
            created_at : db.TIMESTAMP,
            created_by : db.getAuth().uid
        });

        m.route(prefix("/content/" + ctrl.schema.key + "/" + result.key()));
    };
github ArthurClemens / mithril-slider / examples / src / app / index / index.es6 View on Github external
m('span.subtitle', menuItem.subtitle)
        ]));
    })
]);

let app = {};
app.view = () => {
    return m('.index', [
        m('h1', 'Content Slider for Mithril'),
        menu,
        github({home: true})
    ]);
};

m.route.mode = 'hash';
m.route(document.body, '/', {
    '/': app,
    '/images': images,
    '/vertical': vertical,
    '/controls': controls,
    '/ltr': ltr,
    '/group': group,
    '/pages': pages,
    '/multiple': multiple
});
github ScienceCommons / www / client / components / Search.js View on Github external
this.updateSearch = function(e) {
    e.preventDefault();
    m.route("/query/"+encodeURIComponent(_this.query()));
  };
};
github ArthurClemens / polythene / packages / examples / src / index.js View on Github external
const getNewModule = (ln) => {
    if (!ln) {
        return null;
    }
    const dynMod = ln.module;
    return dynMod ? (dynMod.subview ? dynMod.subview(m.route()) : dynMod) : null;
};
github nus-mtp / worldscope / app_server / public / src / js / modules / app.js View on Github external
    '/admins': {controller: () => m.route('/admins/all')},
    '/admins/all': navPage(require('./pages/admins')),