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
dneely
Posts: 3
Registered: ‎05-24-2011
My Device: BlackBerry 9800 Simulator
My Carrier: Verizon

jQuery Blackberry WebWorks Not Working

I have a very simple app. In fact it doesn't really do anything as of yet. I started a new WebWorks project in eclipse. I renamed the latest jquery-release.js to jquery.js and dragged it into the project. I then have the followng code in index.html but yet it does not work in a 6.0 simulator. However, it does work in 5.0. I plan on only supporting 6.0 due to the HTML 5 support for local storage. Please help. 



 

[script src="jquery.js"][/script]

 

[script]

    $(document).load(function(){

         alert ("here");

}

[/script]

Please use plain text.
Developer
praveen_rajan
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: jQuery Blackberry WebWorks Not Working

Hi,

 

Please try this.

 

<script src="jquery.js" type="text/javascript"></script>

 

<script>

    $(document).ready(function(){

         alert ("here");

});

</script>

 

Thanks

Praveen



Please use plain text.
New Contributor
dneely
Posts: 3
Registered: ‎05-24-2011
My Device: BlackBerry 9800 Simulator
My Carrier: Verizon

Re: jQuery Blackberry WebWorks Not Working

[ Edited ]

Thanks for the reply. Must have been a long night and didn't see the obvious on the .ready vs. the .load. Thanks for correcting me on that.

 

I have another issue now where I cannot set onClick functions for a button with an id. I have something like this.

 

<button id="mybutton">Button</button>

 

$("#mybutton").click(function(){

alert("clicked");

});

 

Any thoughts on why this might not work?

Please use plain text.
Developer
praveen_rajan
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: jQuery Blackberry WebWorks Not Working

HI,

 

Please use your jQuery code inside

 

$(document).ready(function(){  });

 

It should work fine then.

 

Thanks

Praveen

Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: jQuery Blackberry WebWorks Not Working

Expanding on the last comment...

 

Some of the apps I have written include a very large number of handlers for user actions, dom and CSS alteration etc

 

Simply put you are not sure until ready() has been called that what things you're trying to do is actually possible at that point

 

You can, safely, call functions you write from within the ready() bit if you're doing any kinf of bind (click being one) how do you know that the button ID actually exists at that point without testing if it's there first? - The only way is a ready()...

 

The same applies to CSS and DOM maniplulation

 

Any direct call to JQuery, not in a function, requires you to know that the bits of the DOM tree you are trying to manipulate actually exist when you do it

 

One of my apps starts off with not much more than a loading message but then alters a load of CSS, inserts lots of elements into a DIV and binds many events - if I don't do that within ready()

 

-----------------

 

 

Kudos button over there -> Go press it :smileyhappy:

 

 




Click the like button if you find my posts useful!
Please use plain text.
New Contributor
dneely
Posts: 3
Registered: ‎05-24-2011
My Device: BlackBerry 9800 Simulator
My Carrier: Verizon

Re: jQuery Blackberry WebWorks Not Working

Thank  you guys for the comments, I really appreciate. These were very noob questions. I'm just getting into BB development (trying WebWorks first). Its been a good long whilce since I've messed with jQuery as well. I'm familiar but apparently have forgotten the basics. Thank you.

Please use plain text.