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

New Member
Posts: 1
Registered: ‎08-12-2012
My Device: BB10Dev Alpha
My Carrier: CMCC

bbui.js, need help

I have developing a new app that use bbui.js, minpubsub.js and jquery,  and now I got a very strange issue, please help.


in the init function, I use minpubsub to publish onscreenready&ondomready events like this:

bb10ActionBarDark: true,
bb10ControlsDark: true,
bb10ListsDark: false,
onscreenready:function (element, id) {
publish("/Views/" + id + "/beforeShow",[element,id]);

ondomready:function (element, id) {
publish("/Views/" + id + "/afterShow",[element,id]);


 then I use minpubsub's subscribe function to process the event, if I write the code like this:



in the loadItemToMainPage function, I use the element argument to modify the page, like this,

var title = element.getElementById("maintitle");


but this does not work, I got this error message:

Uncaught TypeError: Object #<HTMLDivElement> has no method 'setCaption'


but if I wrote code like this:


this code runs successfully.


the second issue:

the loadItemToMainPage function will load some data into image list, and if use click an item, the app will show detail page that show detailed message, but if I put the loadItemToMainPage function in:


and if use click detail page's back button on the actionbar, image list in the main page will be blank.

Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: bbui.js, need help

Please use the "Insert Code" button the add more readability to the post.


For your questions:

Are you using the



when the onscreenready event is fired from the bbUI.JS or ondomready? onscreenready doesn't work since this function is only available after bbUI.js has assigned the style for elements to your screen you inserting.


Have a closer look to the example for bbUI.js Buttons, the setCaption function is used in this way:


document.getElementById('plainBtn').setCaption('my caption');

so the document (DOM) needs to be ready, so you can use it earliest  when the ondomready was fired.


Or you use another way to get it working onscreenready. You can apply the layout for whatever you have at this time when you use something like in the bbUI.js "ondom" function is called. There are a lot of things in there, for example if you want to add the image-list layout at this time you could use:



or for a button use:




BTW: why you are using "publish-before" and "publish-after"  when you are able to do such things using the plain onscreenready and ondomready events together with the "element", where the "element" is your screen to be inserted? I think your code could be much simpler without minpubsub and I can't see why it would be helpful to use minpubsub for your use case.

"Like" if you liked the post.
"Accept as Solution" if the post solves your question.