10-02-2013 04:57 PM - edited 10-02-2013 05:01 PM
For my text area I use the following:
The problem is that in the VMware BB10 emulator and on real BB10 devices the focus is not set to the textarea. Yet, Ripple shows me everything works correct and the textarea gets focus as it should. This script is added after the textform.
I also tried using:
<textarea id="mytextarea" autofocus></textarea>
But this does not work as well. What am I missing about it?
10-03-2013 03:19 PM
10-03-2013 03:26 PM
This is a simplified screen pushed from index.html - exactly in this screen, which is main to my application, the focus is not set to the textarea. I tried both on Z10 and VMware simulator 10.2.0.1155.
Would be grateful for any insight into the problem.
10-03-2013 03:31 PM - edited 10-03-2013 03:32 PM
Ah, so the issue lies with how bbUI.js handles page loading.
The first page that bbUI.js actually loads, we'll call index.html. In there is where we initialize BBUI and then call pushScreen for our very first "actual" page. In our case, let's assume it's for the screen you posted above.
The thing is that bbUI goes through your page and replaces all of the content with its own "formatted" elements. And, at the time of loading the page, the "document" doesn't *actually* contain the "text" element. EDIT: It's still contained in memory; as opposed to existing on the document.
BBUI does provide ondomready events where you can listen for your screen's ID and then take action. However you want to use the "element" variable, instead of "document". Example:
Again, this would be inside the ondomready event, not as an embedded script inside your page. You can find more information for ondomready here:
Let me know if you have any questions.
10-05-2013 10:07 AM - edited 10-05-2013 10:09 AM
Thanks for the links. I went through them, but I still can't get it working.
To get the things most simple for me to figure out, now I decided to modify a little bit the BFB sample app from the Github repository. Sure thing, I didn't forget to add my text field to the main.html screen.
What I did is simply added:
into the welcome() finction of the app (fired at ondomready, actually). I didn't get it working that way (though the Welcome toast is shown, no focus event happens). What is wrong now?
10-05-2013 04:23 PM
10-07-2013 03:22 PM - edited 10-07-2013 03:27 PM
Okay, one more attempt. From the documentation:
You can also be notified when your screen, and all associated <script> tags, have been inserted into the DOM using the ondomready event. This allows you to perform your data manipulation after the screen has been displayed to the user.
So it seems that ondomready should suffice here. Can you please try calling focus() on your element within the ondomready function, however instead of using element.getElementById... you would use document.getElementById... to get the element to call focus() on.
EDIT: Fixed typo.
If that does not work, potentially wrapping the call to focus() inside of a webkitRequestAnimationFrame or setTimeout(..., 0) may do the trick.
If this still does not work, can you please share the full bb.init function you are calling to set up BBUI?
10-15-2013 03:37 PM - edited 10-24-2013 05:16 PM