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 Contributor
mtesm
Posts: 5
Registered: ‎03-18-2011
My Device: 9300
Accepted Solution

Webworks App javascript not loading.

[ Edited ]

My webworks app works perfectly when testing in chrome AND the blackberry playbook simulator browser, but when I compile it to a .bar and send it to the simulator and it loads the app up but only the basic html and not the javascript.

 

****HTML****

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MagicLife</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="ClientCode/jquery-1.5.1.js" type="text/javascript"></script>
<script src="ClientCode/script.js" type="text/javascript"></script>

</head>

<body>

<div id="container">
  <div id="playerone" class="Counter blackplayer">
	  <h1 class="player">name1</h1>
      <p class="life">1</p>
	  <p class="poison">1</p>
  </div>
  <div id="playertwo" class="Counter blackplayer">
	  <h1 class="player">name1</h1>
      <p class="life">1</p>
	  <p class="poison">1</p>
  </div>
 <div id="help">
  ?
  </div>
</div>
</body>
</html>

 ****JAVASCRIPT****(along with jquery)

 

$(function(){
		   $(".Counter").children(".life").html('20');
		   $(".Counter").children(".poison").html('0');
		   $("#playerone").children(".player").html('Player1');
		   $("#playertwo").children(".player").html('Player2');
		   $("#help").toggle(function() {
										 $("#container").addClass("help");
										}, function() {
									     $("#container").removeClass("help");
										});
		   $(".Counter").click(function (e) {										
										   var x = e.pageX - this.offsetLeft;
										   var y = e.pageY - this.offsetTop;
										   var currentlife = parseInt($(this).children(".life").text());
										   var currentpoison = parseInt($(this).children(".poison").text());
										   var currentplayer = $(this).children(".player").text();
										   var player = $(this).attr("id");
										   if (y < 100)
										   {
											newplayer = prompt("Enter your name : ", currentplayer);
											if (newplayer!=null && newplayer!="")
											{
											 currentplayer = newplayer;
											 $(this).children(".player").html(currentplayer);
											 alert("Name changed to : " +  currentplayer );
											}
										   }
										   else if (y > 500)
										   {
										    if (currentpoison > 9)
											{
											 currentpoison = -1;
											}
											currentpoison += 1;
											flashColour("darkgreen", player);
										   }

										   else if (y > 200 && y < 400 && x < 255)
										   {
											currentlife -= 1;
											flashColour("red", player);
										   }
										   else if (y > 200 && y < 400 && x > 255)
										   {
											currentlife += 1;
											flashColour("green", player);
										   }
										   else if (y > 400)
										   {
											currentlife -= 5;
											flashColour("red", player);
										   }
										   else if (y < 200)
										   {
											currentlife += 5;
											flashColour("green", player);
										   }
										   $(this).children(".life").html(currentlife);
										   $(this).children(".poison").html(currentpoison);
										   });
		   });
	function removeadd(Colour, Player) {
		$("#"+Player).removeClass("blackplayer").addClass(Colour+"player");
	}
	function addremove(Colour, Player) {
		$("#"+Player).removeClass(Colour+"player").addClass("blackplayer");
	}
function flashColour(Colour, Player) {

		setTimeout(function(){removeadd(Colour, Player)},100);
		setTimeout(function(){addremove(Colour, Player)},250);
}

 

****CONFIG.XML****

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0" rim:header="RIM-Widget:rim/widget">
  <name>MagicLife</name>
  <description>Testing</description>
  <author rim:copyright="2011">n/a</author>
  <icon rim:hover="false" src="icon.png"/>
  <icon rim:hover="true" src="icon.png"/>
  <content src="index.html"/>
  <access uri="*" subdomains="true"></access>
</widget>

 

 

 

Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Webworks App javascript not loading.

Is your application pulling in any external content? and if so, have you white listed the origins?

 

Which version of the WebWorks Beta are you using and which version of the PlayBook Simulator are you using?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
mtesm
Posts: 5
Registered: ‎03-18-2011
My Device: 9300

Re: Webworks App javascript not loading.

It's not pulling anything from outside the application.. I'm using the v1.0.0.23 Beta3 of webworks and v0.9.4 of the playbook sim i believe.. is there any way to check? i downloaded and installed them recently.

New Contributor
mtesm
Posts: 5
Registered: ‎03-18-2011
My Device: 9300

Re: Webworks App javascript not loading.

updated original post to include config.xml which I'm not sure if i did right.

Contributor
hakanson
Posts: 36
Registered: ‎04-06-2010
My Device: Bold 9700

Re: Webworks App javascript not loading.

I see you are using jQuery 1.5.1.  There is a thread in this forum titled "JQuery 1.5.1 does not work on the PlayBook simulator."  Not sure if that is the problem, but worth a look.

New Contributor
mtesm
Posts: 5
Registered: ‎03-18-2011
My Device: 9300

Re: Webworks App javascript not loading.

Thank you. http://supportforums.blackberry.com/t5/Web-Development/Caution-JQuery-users-JQuery-1-5-1-does-not-wo... just posting this here incase someone else wants to know XD

New Contributor
mtesm
Posts: 5
Registered: ‎03-18-2011
My Device: 9300

Re: Webworks App javascript not loading.

craaap.. i didn't test that before accepting your solution.. it still doesn't work with 1.5 :smileysad: