If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Trusted Contributor
sergiosandoval
Posts: 132
Registered: ‎02-17-2012
My Device: Bold 9900
My Carrier: AT&T
Accepted Solution

JS error

I keep getting these errors when I add a few lines of code to my JS file. 

 

 

Am I calling something with the same name as something from the BBUI's or the webworks?

 

 

I have tested my app with out the BBUI's and the webworks stuff but once I add BBUI's and the webworks files I get the same errors and my app wont function.

 

 

http://i391.photobucket.com/albums/oo354/sergio112_nitto/Untitled-1-3.jpg

 

 

 

I can add my code if I have too.

Please use plain text.
Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: JS error

Adding the code should help in determining what the issue is.
Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Please use plain text.
Trusted Contributor
sergiosandoval
Posts: 132
Registered: ‎02-17-2012
My Device: Bold 9900
My Carrier: AT&T

Re: JS error

[ Edited ]

Here is the screen shot from my .JS file

 

http://i391.photobucket.com/albums/oo354/sergio112_nitto/code.jpg

'use strict';

var count = 0;
var interval_id = null;

var schedule = null;
var schedule_index = null;

var beep = new buzz.sound('J:/wamp/www/TESTSOUND/audio/beep', {formats: ['ogg', 'mp3']});
var high_beeps = new buzz.sound('J:/wamp/www/TESTSOUND/audio/high', {formats: ['ogg', 'mp3']});
var normal_beeps = new buzz.sound('J:/wamp/www/TESTSOUND/audio/normal', {formats: ['ogg', 'mp3']});





$(document).ready(function () {
	$('#start').click(start);
	$('#stop').click(stop);
	
	$('#settings-fields > input[type="text"]').blur(clean_input);
	
});

function start() {
	toggle_buttons();
	build_schedule();
	
	count = schedule[0].seconds;
	$('#section-title').html(schedule[0].title);
	$('#countdown').html(count);
	interval_id = setInterval(tick, 1000);
}

function stop() {
	clearInterval(interval_id);
	
	$('#countdown-area').removeClass();
	$('#section-title').html('Done');
	$('#countdown').html(0);
	toggle_buttons();
}

 

Please use plain text.
Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: JS error

Where does buzz come from? Is it a library you're using?

Looks like it's not included.
Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Please use plain text.
Trusted Contributor
sergiosandoval
Posts: 132
Registered: ‎02-17-2012
My Device: Bold 9900
My Carrier: AT&T

Re: JS error

but the code works when i dont have the BBUI and webworks on it. 

 

 

im calling the buzz file from my index.html should i call .buzz on the js file?

Please use plain text.
Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: JS error

Try moving your code to a js file. Also, are you listening for the webworksready event (BB 10)?
Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: JS error

The issue is that you are likely calling your code that touches an item that isn't yet in the dom.

 

Here's the order of operations from opening a screen:

- pushScreen() is called

- Screen is loaded into memory

- onscreenready is fired for that new screen where you can manipulate its contents

- The screen styling is then applied

- Screen is inserted into the live DOM

- ondomready is then fired

 

My guess is that you have a race condition trying to call your screen DOM element and it isn't loaded.  You must wait for the ondomready event for your screen before you can manipulate its contents with jQuery.  jQuery assumes your content is in the live DOM of the document.  However with bbUI, the screen isn't in the live DOM until after the ondomready event is fired.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: JS error

Tim is correct. I totally forgot you're doing this within the context of bbUI.
Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Please use plain text.