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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Can a bbui first screen have attached js?

So my first page (index.html) has code:

 

<html>
<head>
<meta name="x-blackberry-defaultHoverEffect" content="false" />
<meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=no,target-densitydpi=device-dpi" />
<link  rel="stylesheet" type="text/css" href="bbui-0.9.4.css" />
<link rel="stylesheet" href="leaflet.css" />
<script type="text/javascript" src="leaflet.js"></script>
<script type="text/javascript" src="bbui-0.9.4.js"></script>
<script type="text/javascript">

var fs_id = '';
var sp_id = '';
var rv_id = '';
var use_i = '';
var gps_c;

bb.init({
	bb10ActionBarDark: true,
	bb10ControlsDark: true,
	bb10ForPlayBook: true,
	ondomready: function (element, id) {
	if (id == "profile") {
		doRecallProfile();
    } else if (id == "reporttime") {
		reporttime_addListItem();
	} else if (id == "studydetails") {
		studydetails_addListItem();
	} else if (id == "showreturns") {
		returndetails_addListItem();
	} else if (id == "edittime") {
		edittime_updateInputs();
	} else if (id == "editinterest") {
		editinterest_updateInputs();
	} else if (id == "editstudy") {
		editstudy_updateInputs();
	} else if (id == 'map_screen') {
		create_map();
	}
  }
});

</script>
</head>
<body onLoad="bb.pushScreen('menu.html', 'dashboard');">
</body>
</html>

My question is:  Can the first page -> menu.html have an attached javascript file that gets run much like the profile and other pages I have here?

 

I tried placing an id here for 'dashboard' but it comes up blank and I get "Cannot set property 'innerHTML' of null" errors meaning that the DOM is not ready or loaded.

 

suggestions?

 

If it helped you, click like. Smiley Happy
BlackBerry Development Advisor
Posts: 769
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Can a bbui first screen have attached js?

Hello,

 

You can include inline scripts like this:

 

<div data-bb-type="screen" data-bb-effect="slide-left">
	<script id="actionBarJS" src="js/actionBar.js"></script>

<script>
console.log('this is an inline script');
</script>
</div>

 

Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: Can a bbui first screen have attached js?

Tried that, didn't work.

 

Also I just read today on the bbui.js wiki that you cannot include inline js when using pushscreen, so your suggestion although a good one has no effect.  Unless I did it wrong of course.  I think the wiki info still stands though.

If it helped you, click like. Smiley Happy
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Can a bbui first screen have attached js?

To use inline JS when using bbUI.js I recommend to use the onscreenready and/or ondomready events for such things. With this you are able to call "inline" JS if neccessary when the screen was added. Have a closer look to the Toolkit Initialization wiki page for more informations.

 

And there is also the wiki page about Screen Specific CSS and JavaScript that attributes things that might be interesting for you. The page covers how to add CSS and JS by source and also as inline elements directly.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
BlackBerry Development Advisor
Posts: 769
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Can a bbui first screen have attached js?

Hi there,  did LBP's suggestion work for you?  

 

If so could you please mark it as an accepted solution?  If not, let us know Smiley Happy

Developer
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: Can a bbui first screen have attached js?

Sorry haven't been able to get back to my app to try that suggestion.  Will try it over the next few days.  Tx for the feedback.

If it helped you, click like. Smiley Happy