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 Developer
Posts: 13
Registered: ‎12-14-2009
My Device: 9000
My Carrier: Idea
Accepted Solution

JavaScript not loading

HI,

 

I am trying to make a Sqlite project using gears API. I have downloaded the gears_init.js file locally. The sample application for Gears povided by BB is woking fine. But when I am tring to modify the same & use in my application the javascripts do not load. The index.heml page is loaded but none of the javascripts are invoked.

 

BB simulator : Storm 9550, 5.0.0.469

Browser :blackberry

N/w : both CDMA & GSM

 

THe index.html file:

 

title>Data Storage Example</title>
    <link href="Styles/styles.css" rel="stylesheet" type="text/css" />
    <script src="http://www.google.com/jsapi?key=ABQIAAAAsm1sbQmJWbgLoP7i4K2WdBR_SoAUqeLrvjUVmFG1nkbo-KiRrxRswNhze0oP..." type="text/javascript"></script>  
    <script src="Scripts/action.js" type="text/javascript"></script>
    <script src="Scripts/gears_init.js" type="text/javascript"></script>
    <script type="text/javascript">
    function myAlert(){
    	alert("Alert from HTML");
    }
    </script>
</head>
<body onload="javascript&colon; demoAlert(); myAlert(); openDatabase(); populateShoppingListTable()">
	<div>
	    <p class="header">Save shopping list items</p>
	</div>
    <div>
		<p class="listTitle">Items</p>
		<input type="text" id="txtItem" />
		<br/>
		<br />
		<input type="button" value="Add item to list" onclick="addShoppingListItem(document.getElementById('txtItem').value)" />
	</div>

 

 

The action.js file:

 

// Global handle to the database
var _db;

// Open the database using Google Gears API and create a table if needed
function openDatabase() {
	alert("kasiey ho anna");
    var db = google.gears.factory.create('beta.database1');
    db.open('itemSet1');
    db.execute('create table if not exists ShoppingListTable (Serial text unique, ItemName text, PurchaseStatus text, Rate text, Qauntity text)');
    _db = db;
}

function demoAlert(){
	alert ("I am  a jokings");
}

// Save the selected Items
/*function saveItems(item) {
    try {
        // Add the link into the database if the checkbox is checked
        _db.execute('insert into Items values (?)', [item]);
        // Update the table
        populateTable();
    }
    catch (e) {
        alert(e);
    }
}*/

function addShoppingListItem(itemname) {
    try {
    	alert(itemname);
    	var count = _db.execute('Select COUNT(ItemName) from ShoppingListTable');
    	var serialNum = count+1;
        // Add the link into the database if the checkbox is checked
        _db.execute('insert into ShoppingListTable (Serial, ItemName) VALUES ('+ serialNum + ', '+itemname+')');
        //@@@@@@@@@@@@@@@@@Select COUNT(Supplier_ID) from suppliers
        // Update the table
        populateShoppingListTable();
    }
    catch (e) {
        alert(e+"In add Shopping Item");
    }
}

 

Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: JavaScript not loading

Check your onload statement

 

 

<body onload="javascript&colon; demoAlert(); myAlert(); openDatabase(); populateShoppingListTable()">

 

what does "javascript&colon;"  perform?

 

_________________________________________
www.jasonmace.com/blackberry
Developer
Posts: 86
Registered: ‎06-05-2009
My Device: Bold 9900 7.1
My Carrier: T-Mobile Germany

Re: JavaScript not loading

 

Also, I believe that:

"google.gears.factory.create('beta.database');"

is a fixed term, so you cannot change the classname to "beta.database1".

If you want to change the database name, you have to change the parameter for "db.open('database1')".

 

I think, this one will cause problems, too - I may be wrong, though.

_db.execute('insert into ShoppingListTable (Serial, ItemName) VALUES ('+ serialNum + ', '+itemname+')');

Instead use:

_db.execute('insert into ShoppingListTable (Serial, ItemName) values (?,?)', [serialNum, itemname]);

New Developer
Posts: 13
Registered: ‎12-14-2009
My Device: 9000
My Carrier: Idea

Re: JavaScript not loading

Along with this I also had to change some other JScripts which were giving errors.

Highlighted
New Member
Posts: 1
Registered: ‎07-24-2011
My Device: 8250
My Carrier: airtel

Re: JavaScript not loading

Can I play facebook game farmvilla at my BB