- This topic has 6 replies, 2 voices, and was last updated 9 years, 10 months ago by Darshan Patel.
-
AuthorPosts
-
Darshan PatelParticipantmy device ready function seems to be executing before the device is ready…
this is the code
phoneui.documentReadyHandler = function() {
alert(device.uuid);
}its shows error : Uncaught ReferenceError: device is not defined
this was working fine till now.. but it started to show error when i changed my first page to some other page…
so i also tried creating a new blank project but still it shows the same error…
i have found the workaround for this… but still can you please check what the issue is?
thanks..
support-michaelKeymaster>its shows error : Uncaught ReferenceError: device is not defined
>this was working fine till now.. but it started to show error when i changed my first page to some other page…2 thoughts:
1) compare your new start page to the original working page. Make sure you are including cordova.js correctly2) if the new startup page has a different name then in your config.xml file make sure the following entry is properly configured with the startup file name.
<content src=”yourstartupfile.html”/>
Optionally if your startup file is named index.html you can remove or comment out the <content> element.
Lastly, how are you building your project?
Darshan PatelParticipanti am using M1..
i tried this thing in a fresh project.. still the same error..
the issue is that the device info is not available when deviceready is fired.. it is available a sec later..
like this doesnt works
phoneui.documentReadyHandler = function() {
alert(device.uuid);
}but this does
phoneui.documentReadyHandler = function() {
setTimeout(function (){alert(device.uuid);},1000);
}
support-michaelKeymasterI’ll try replicating this. Please provide the following info:
1) What mobile platform, ios or android?
2) How are you building the project? Are you using MobiOne to build the app or another mechanism such as MyEclipse + PhoneGap Build or a local SDK?
3) Can you share a small sample project that demo’s this issue?
I can gen one but then it will not be a true apples-apples test.
Darshan PatelParticipant
support-michaelKeymastermy apologies as I had a brain fart last week thinking you were receiving a deviceready callback…
Here’s the approach you should take. In your documentReadyHandler() function register the phonegap/cordova deviceready event handler. That should do it. The documentReadyHandler() is call when the html document completes loading. You must wait for cordova to send the deviceready event before using any cordova or plugin api.
phoneui.documentreadyhandler = function() { document.addEventListener("deviceready", function() { alert(device.uuid); } }
Darshan PatelParticipantthanks…
-
AuthorPosts