Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Trusted Contributor
bertho_joris
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780
My Carrier: Telkomsel

Using ondomready and onscreenready function in bbUI

[ Edited ]

I want to ask for that use as well bbUI. I use the function ondomready like this : index.html

ondomready: function(element, id) {
    if (id == 'NowPlaying') {
        NowPlaying_initialLoad(element);
    }


And when I call the page using the retrieval of data from my server, then all went well and without a hitch : process.js

 

function NowPlaying_initialLoad(element) {
    setTimeout(NP_loadAfterTimeout, 10000);
}

function NP_loadAfterTimeout() {
    document.getElementById('waiting').style.display = 'none';
    NowPlayingProses_initialLoad()
}

function NowPlayingProses_initialLoad() {
        //My Code to process data from my server
}

 
 As a result, all went well. But there are a few that I wanted to ask.


1. Once the page is loaded, then appeared loading.gif as display data loading process is underway for 10 seconds.

Do this for 10 seconds (when the loading image appears) the application automatically performs data requests to the server will wait for me or after 10 sec (loading image hide) a new application of the process of reading data from my server?

What I discovered after trying to live on the BB OS6, it was not like that. Not the process of reading the data to the server for loading images appear on the screen. After missing image loading new applications perform data readout and takes a few seconds to do this.
This resulted in a blank screen in a few seconds, before the data has been read and displayed on the screen.

 
2. Would this not be done like this:
- Pages opened and show pictures loading.gif
- During the 10 second run, the application will automatically read the data from the server.
- When the 10 seconds expires, the image loading will be lost and at the same time direct data displayed on the screen, or for NOT READ ALL DATA FROM SERVER, image loading will continue to be shown on the screen and then disappear once all data has been read.



3. How do I use the onscreenready function, To get around this so that the screen is not empty as was the case above.

 

 

Please see the picture below, to see the way that I ask the application match the above :

1. Menu Application Picture
http://s14.postimage.org/pwqqodxzl/Menu.png

2. Loading Data Picture (10 seconds)
http://s9.postimage.org/or85dx4vz/Loading.png

3. Blank Screen (After Image Loadiing hide)
http://s10.postimage.org/syjsnaskp/Blank_Screen.png

4. Data Show (After a few seconds)
http://s15.postimage.org/jq1tecrtn/Data_Loaded.png

Regards,
Bertho
Please use plain text.
Trusted Contributor
bertho_joris
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780
My Carrier: Telkomsel

Re: Using ondomready and onscreenready function in bbUI

waiting...:Cowboy:

Regards,
Bertho
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Using ondomready and onscreenready function in bbUI

Have you checked out the Data On the Fly sample that is part of the bbUI repo.. it sounds like it does exactly what you're looking for

 

https://github.com/blackberry/bbUI.js/blob/master/samples/dataOnTheFly.htm

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Trusted Contributor
bertho_joris
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780
My Carrier: Telkomsel

Re: Using ondomready and onscreenready function in bbUI

[ Edited ]

What do you mean by it sounds like it does exactly what you're looking for?
Is there something wrong with my code writing or reading data logic?

 

The application that I made was taking the example of the function you give it. how the apps that I mean: When I access the page, I will read all the data from my server. During the reading of my data, pictures loading.gif will always appear on the screen until all the data is ready for my show. And all of it has been running fine on my application. It's just as I asked above. Is loading.gif look at the picture, the app is reading the data on my server or wait for image finished loading a new check to the server?

Regards,
Bertho
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Using ondomready and onscreenready function in bbUI

I'm still not sure that I understand your question then.  If you are looking to have a "loading" image while you are bringing in content from a server, and not have delays between when the loading is shown and the content is shown you need to do the following

 

  1. pushScreen() -> With a screen that has the loading animation on it
  2. ondomready -> Do you Ajax calls for data from the server
  3. Create your resulting DOM elements in a document fragment and style them accordingly
  4. Once you have finished styling them, remove the loading animation and insert your new DOM elements

It is also best to do all of your processing in a worker thread so that when you are doing your requesting/styling that you are not blocking the UI thread.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.