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

router init method

6 Answers 134 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 18 Mar 2015, 08:24 PM
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

6 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 20 Mar 2015, 09:21 AM
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!
 
0
Josh
Top achievements
Rank 1
answered on 20 Mar 2015, 02:16 PM
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
0
Accepted
Petyo
Telerik team
answered on 21 Mar 2015, 02:19 PM
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!
 
0
Josh
Top achievements
Rank 1
answered on 23 Mar 2015, 06:13 PM
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.
0
Josh
Top achievements
Rank 1
answered on 24 Mar 2015, 01:25 PM
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?
0
Petyo
Telerik team
answered on 25 Mar 2015, 12:08 PM
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!
 
Tags
MVVM
Asked by
Josh
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Josh
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or