router init method

7 posts, 1 answers
  1. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 18 Mar 2015 Link to this post

    Hi,

    Currently using version "2014.2.716"

    I have code using the router 'init' method. I went looking for documentation on this method but couldn't find any... I could have sworn there used to be some somewhere. Is there documentation of this method somewhere?

    Thanks,
    Josh
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 20 Mar 2015 Link to this post

    Hello Josh,

    Each widget has private init method that initializes the component. It is not recommended to call or modify that method which is why it is not documented.

    Regards,
    Alexander Valchev
    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. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 20 Mar 2015 in reply to Alexander Valchev Link to this post

    Thanks Alexander.

    Can you say why it is not recommended to utilize router.init? I find it quite useful for doing some UI and other initialization tasks before the first route is called.

    .. Josh
  5. Answer
    Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 21 Mar 2015 Link to this post

    Hello Joshua,

    Perhaps you refer to the router init event (which is different than the init method). Indeed, it is not a documented one; The init event will be triggered synchronously when you call the start() method, so you can put your code before the start method instead.

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 23 Mar 2015 in reply to Petyo Link to this post

    Bah, right you are... sorry, I confused the event and method. Still, it seems you are recommending not using the init event and instead just put code before the start() method. Why is that? Putting initialization in the init event seems to be more clear.
  7. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 24 Mar 2015 Link to this post

    By the way, I finally tracked down where I saw the usage of the init event and why I was using it. It's in your very own sushi SPA demo:

    var sushi = new kendo.Router({
        init: function() {
            layout.render("#application");
        }
    });

    So... why is it not recommended for use and also not documented?
  8. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 25 Mar 2015 Link to this post

    Hi Joshua,

    that's a good one! indeed we use it in the demo, and it is by mistake. The reason why we keep it undocumented is because it adds no additional objective value, while creating the false perception that the router has an asynchronous instantiation (which is not the case). 

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready