Get route definition in route method callback

3 posts, 0 answers
  1. olivier
    olivier avatar
    14 posts
    Member since:
    Feb 2011

    Posted 02 Dec 2013 Link to this post

    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. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 03 Dec 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. olivier
    olivier avatar
    14 posts
    Member since:
    Feb 2011

    Posted 04 Dec 2013 Link to this post

    Thanks Kiril! Very helpful.
Back to Top