03-18-2011 08:28 PM - edited 03-18-2011 09:55 PM
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").addClas s("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>
Solved! Go to Solution.
03-18-2011 08:55 PM
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?
03-18-2011 09:15 PM
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.
03-18-2011 09:55 PM
updated original post to include config.xml which I'm not sure if i did right.
03-19-2011 01:30 PM
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.
03-20-2011 04:42 PM
Thank you. http://supportforums.blackberry.com/t5/Web-Develop
03-20-2011 04:57 PM
craaap.. i didn't test that before accepting your solution.. it still doesn't work with 1.5