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

Automatic init event on all Views

4 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 20 Jun 2013, 02:59 PM
Hi guys

Is there a way to attach the same init method (beforeShow and show too) to all Views, without specifying on html? Or maybe a way to bind to an event that gets triggered from all Views?

I think a good way to solve this would be the possibility to specify the View init method through the Layout. I have many Views with the same Layout, and all of them use the same init and show method. If we could put that in the Layout, the markup would become simpler and more maintainable.

Thanks!

4 Answers, 1 is accepted

Sort by
0
Dean
Top achievements
Rank 1
answered on 24 Jun 2013, 12:09 AM
Hi Fernando,

In my application I've used the 'viewShow' and 'navigate' events of the pane. These events are triggered for all views. You can read about it in the docs.

For example:
app.pane.bind("navigate",
    function() {
        console.log("app.pane.navigate");
    }
);
app.pane.bind("viewShow",
    function() {
        console.log("app.pane.viewShow " + app.pane.viewEngine.url);
    }
);
0
Fernando
Top achievements
Rank 1
answered on 24 Jun 2013, 08:08 PM
Thanks, I'll try that!
0
Fernando
Top achievements
Rank 1
answered on 24 Jun 2013, 09:04 PM
A viewInit event on the Pane (or something like that) would be really useful. The navigate event does not give the reference to the new View being constructed.
0
Petyo
Telerik team
answered on 26 Jun 2013, 01:41 PM
Hi Fernando,

Thank you for the suggestion. We will consider exposing such event for our future releases.

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Fernando
Top achievements
Rank 1
Answers by
Dean
Top achievements
Rank 1
Fernando
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or