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

How can I let Kendo UI wait for deviceReady event?

2 Answers 265 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jan-Dirk
Top achievements
Rank 1
Jan-Dirk asked on 25 Mar 2013, 01:55 PM
I have a Kendo application construction with an initialization which contains a call bindevents() that in it's turn adds the event listener for deviceReady.

Before deviceready is finished the code for my homeView_onInit is already being executed causing incorrect behaviour of my app

How can I prevent that any code is executed before the deviceready event has finished or is fired?

2 Answers, 1 is accepted

Sort by
0
Dean
Top achievements
Rank 1
answered on 25 Mar 2013, 10:32 PM
You can bind to the deviceReady event before you create a kendo application, and instead create the kendo application within the deviceReady event handler to achieve the sequence you want. For example:

        <script>
            //declare the application variable globally
            var app;

            // Wait for PhoneGap to load
            document.addEventListener("deviceready", onDeviceReady, false);
            
            // PhoneGap is ready
            function onDeviceReady() {
                app = new kendo.mobile.Application(document.body, { transition: "slide" });
                navigator.splashscreen.hide();
            }
        </script>
0
Jan-Dirk
Top achievements
Rank 1
answered on 26 Mar 2013, 01:13 PM
Aargh... Of course...

*walking away with red head from shame*
Tags
General Discussions
Asked by
Jan-Dirk
Top achievements
Rank 1
Answers by
Dean
Top achievements
Rank 1
Jan-Dirk
Top achievements
Rank 1
Share this question
or