10 examples of 'backbone router events' in JavaScript

Every line of 'backbone router events' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
68function Router_(defaultRouteName, opt_defaultRouteArgs,
69 opt_defaultCallbackArgs) {
70 window.router = this;
71 /**
72 * @type {string}
73 * @private
74 */
75 this.defaultRouteName_ = defaultRouteName;
76 /**
77 * @type {Array}
78 * @private
79 */
80 this.defaultRouteArgs_ = opt_defaultRouteArgs || [];
81 /**
82 * @type {Array}
83 * @private
84 */
85 this.defaultCallbackArgs_ = opt_defaultCallbackArgs || [];
86 /**
87 * @type {Route}
88 * @private
89 */
90 this.currentRoute_ = null;
91 window.addEventListener('popstate', _.bind(this.handlePop_, this));
92}
27fire(route, event = 'init', arg) {
28 const fire = route !== '' && this.routes[route] && typeof this.routes[route][event] === 'function';
29 if (fire) {
30 this.routes[route][event](arg);
31 }
32}
495route(event) {
496 return router(event);
497}
89setRouter (router) {
90 if (this.router) {
91 this.router.off("changed", this._onChanged, this);
92 }
93 if (router) {
94 router.on("changed", this._onChanged, this);
95 }
96 this.router = router;
97}
133route: function route(router, method, path, callback) {
134 method = method.toUpperCase();
135 this.handlers.unshift({ router: router, method: method, route: path, callback: callback });
136},
47on(route,callback){
48 const newRoute={
49 pattern:route,
50 callback:callback
51 };
52 this.routes.push(newRoute);
53 if(window.location.pathname.match(route)){
54 this.setActiveRoute(window.location.pathname,newRoute);
55 }
56}
312private dispatchRouterNavigated(event: NavigationEnd): void {
313 const routerState = this.serializer.serialize(
314 this.router.routerState.snapshot
315 );
316 this.dispatchRouterAction(ROUTER_NAVIGATED, { event, routerState });
317}
17constructor(args: RouterArgs = {} as RouterArgs) {
18 super(args);
19
20 // The direction user navigates in
21 this.direction = args.direction || 'forward';
22
23 // Override normal direction
24 this.directionOverride = null;
25
26 // Number of views navigated
27 this.viewCount = args.viewCount || 0;
28
29 // Stack of previous routes
30 this.prevRouteStack = [];
31
32 // Extend the existing history object
33 this.extendHistory();
34
35 // Wait for transition to finish before confirming navigation
36 this.extendTransitionConfirmation();
37
38 // Listen to Ionic's back button event
39 document.addEventListener('ionBackButton', (e: Event) => {
40 (e as BackButtonEvent).detail.register(0, () => this.back());
41 });
42}
32init() {
33 window.addEventListener('load', this.updateView.bind(this), false);
34 window.addEventListener('hashchange', this.updateView.bind(this), false);
35}
545private static _onHashChange(event):void
546{
547 if (Router.allowManualDeepLinking === false && Router.useDeepLinking === false)
548 {
549 return;
550 }
551
552 Router._hashChangeEvent = event;
553
554 const hash = Router.getHash();
555
556 Router._changeRoute(hash);
557}

Related snippets