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
New Developer
Posts: 13
Registered: ‎01-05-2012
My Device: Bold 2
My Carrier: GLO

Issues With BBUI

Hi everyone,

I am using BBUI.js for the UI of a Blackberry app am working on presently.

I wnat this code to be executed before a page is rendered 

 

 function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } 

 

But the problem is that  i dont know how to do it using the 

bb.onscreenready = function(element, id) {

 Would be grateful if i can be shown the way out.

Contributor
Posts: 13
Registered: ‎03-06-2012
My Device: 9930, 9900
My Carrier: -

Re: Issues With BBUI

window.onload = function() {

 

// Your code execution here!!!

 

}

Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900
My Carrier: Rogers

Re: Issues With BBUI

To use that function on your index page you need to add this code:

 

bb.onscreenready = function(element, id) { 
if (id == 'game') { 
//run functions or code when the screen 'game' becomes available
}else if (id == 'rules'){ //run functions or code when the screen 'rules' becomes available
}

 Where the id matches the id you gave the screen when you add it. ie.

bb.pushScreen('game.html', 'game');

 But this code runs once the screen is loaded not before, you could not initially have the item you are working with in the DOM and add it after the page loads once you run your limitText function on it.

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful