09-21-2012 04:30 PM
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?
09-24-2012 08:10 AM
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>
09-24-2012 12:31 PM
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.
09-25-2012 07:40 AM
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.
10-01-2012 11:07 AM
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 ![]()
10-02-2012 02:51 AM
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.