This is a migrated thread and some comments may be shown as answers.

Get route definition in route method callback

2 Answers 53 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Olivier
Top achievements
Rank 1
Olivier asked on 02 Dec 2013, 11:12 PM
Hi!

I'm implementing a function that will be used as callback for several routes in my SPA. My challenge now is that I don't know how to get the route definition inside the function. For example:

var callback = function(){
   ///How to get the according route definition? For instance: "/login", "/main", "/items/:category/:id"
}

router.route("/login", callback);
router.route("/main", callback);
router.route("/items/:category/:id", callback);

Does the Kendo API provide a way to get that information?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 03 Dec 2013, 08:32 AM
Hi Olivier,

You can get the route definition inside the callback of the route() method using something like this:

function handleRoute(route) {
   router.route(route, function() {
      console.log(route)
   }
}
  
handleRoute('/login');
handleRoute('/main');

 
Regards,

Kiril

Telerik Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Olivier
Top achievements
Rank 1
answered on 04 Dec 2013, 07:59 PM
Thanks Kiril! Very helpful.
Tags
SPA
Asked by
Olivier
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Olivier
Top achievements
Rank 1
Share this question
or