blackberry / bbUI.js

BlackBerry UI look and feel JavaScript toolkit for WebWorks
Apache License 2.0
312 stars 192 forks source link

Smartphone Test Device Not Showing the splashscreen #923

Closed ghost closed 10 years ago

ghost commented 11 years ago

I have tested my application using Ripple Emulator, and Dev Alpha Simulator 10.1. The application works and is being rendered in those test devices. However when I installed it to either BB Z10 Dev Alpha B or BB Q10 Dev Alpha C devices the application does not show the splashscreen which is a show stopper for the app.

I used http://jsconsole.com/ to remotely view the console logs of the app and in the device it encounters a null error in bbui.js at function initContainer at line which executes the code below:

    document.body.appendChild(container); 

The JSConsole returns that line as TypeError: 'null' is not an object

I output the container variable and it is not null but an object of type HTMLDivElement.

Can I ask for advise on how to resolve this error?

Thanks!

Btw, I used version 0.9.6.280 of bbui.

tneil commented 11 years ago

Are you listening for the webworksready event before calling bb.init()

ghost commented 11 years ago

yes I am calling bb.init() to the webworksready event listener. The pattern for the code I used is like the code below.

      document.addEventListener('webworksready', function(e) {
                    ...
                    var config = {controlsDark: false,
                                    listsDark: false,
                                    coloredTitleBar: true};
                    config.onscreenready = function(element, id, data) {  ... }
                    config.ondomready = function(element, id, params) { ... }

                    bb.init(config);
                    ...

                    bb.pushScreen("splashscreen.htm" , "splashscreen", {});
      }, false);
tneil commented 11 years ago

Do you have old sample code that used to check to see if it was BB10 and then also create and fire a webworksready call.

Double check the BB10 sample code and make sure that you aren't raising a second webworksready event by accident. If this happens, then it will fire before the webworksready event and you will get a blank screen.

ghost commented 11 years ago

I already replaced the event listener for load event as coded in the link you provided. Unfortunately, it is still a black screen and the same error at the initContainer function.

tneil commented 11 years ago

It's hard to tell from the details you have posted so far. I typically go by what I have in the sample application that is used for all my testing which works on all devices, Ripple and simulators

tneil commented 11 years ago

I would also suggest using the latest version of bbUI which has the most up to date code

ghost commented 11 years ago

I already used the recent js and css in the app.

I just observed that in simulator DOM are initialized before executing the bb.pushScreen function unlike in the device, the DOM has not yet initialized before executing the bb.pushScreen that is why the black screen is being displayed in the app.

The workaround I created regarding the issue, since I am also using JQuery in the app, is to execute the bb.pushScreen within a dom ready event.

Thanks for the help.

tneil commented 11 years ago

That is really strange that the webworksready event is firing before the dom is ready. I have never seen this happen on any OS version either internal and external. Is there any way you can post the full contents of your index.htm file for me to see?

theclabs commented 11 years ago

Hi @tneil im have the same problem, TypeError: 'null' is not an object evaluating ( document.body.appendChild(container); This error occurs on line 341 of the version 0.9.6.687 of bbui.js ( https://github.com/blackberry/bbUI.js/blob/master/pkg/bb10/bbui.js#L341 ). evaluating the following exprecion I think the problem is due to that, try to insert the scripts before they finished loading the body. has there been a similar report? I wait your answer in the meantime I will check your commit https://github.com/blackberry/bbUI.js/commit/43d619c3c7d7caf93b1138e713a48d9e339f3b72

many tanks, regards, from BB TechCenter San Luis, Argentina

tneil commented 11 years ago

Make sure you are first listening for the load event on window, before attaching your listener for the webworks ready event. https://github.com/blackberry/bbUI.js/blob/master/samples/bb10/index.htm#L28