09-04-2012 05:04 AM - edited 09-04-2012 05:06 AM
I want to make my connection to the database server using jquery. But I wonder how can I modify the example code from my jquery into bbui rules.
My code : http://pastebin.com/LfGCPU7D
I want to make it work well as examples of self BBUI : http://pastebin.com/VgsKRz4N
I use the sample : Load Data After Showing (dataOnTheFly.htm)
09-05-2012 03:06 AM
First of all, if you want to do, you need to rewrite the ajax call to use the plain XMLHttpRequest. Some nice examples are available here: https://developer.mozilla.org/en-US/docs/DOM/XMLHt
For the dataList elements you should have a closer look to the bbUI.js wiki page for the image-lists. I think there are enough samples to get started!!
If the ajax call and the response/success functionality is all you are using jQuery for I would recommend to not use it since using a "big" (in size) framework like jQuery for only some calls/use cases doesn't make any sence for me.
09-05-2012 03:52 AM
As far as I know there are some issue when using frameworks, but I think Tim from RIM will fix those things if he knows. I, by myself do not use frameworks if I only need to do some small things that can be done with some lines of code I wrote myself and also I understand since this might be essential when debugging, to understand the used code.
For your example I think you can go on using the jQuery Ajax source if you want to but for bbUI.js image-list you need to go deeper into bbUI functionality. I also think it should be that much to be done to get it working, but it would be good to know how it should look like.
09-05-2012 09:49 AM
The trick to manipulating the UI in your bbUI application is understanding the onscreenready and ondomready events. If you are looking to manipulate the screen using jQuery selectors $('mydiv') then you must wait until the ondomready event fires so that your screen is in the live document
09-05-2012 10:46 AM
No.. the bbUI.js ondomready function that will fire for each screen you load
09-05-2012 11:03 PM
Is bb.init function should always be placed on each page?
Or just put on index.htm as in the example of your page?
Will I still be able to use the $. Ajax as my example, or have to adjust to the style of your example?
09-06-2012 01:11 AM
You only need to init bbUI one time on the index.html (or whatever is configured in your config.xml). Within the bb.init(...) you define what to do ondomready and onscreenready. With bbUI.js you also easily switch between screens, not complete pages.
Since you want to use jQuery, I think this is what Tim mentioned before, your source code needs to be called in bbUI's ondomready handler in the bb.init(..).
Have a closer look to the repo sample of the index.htm at line 64: https://github.com/blackberry/bbUI.js/blob/master/
At this time the DOM is ready, so you could use jQuery directly to run your source code. I think to make it working as a sample and to understand how it works add your source within the "dataOnTheFly_initialLoad" function in the dataOnTheFly.js file from the bbUI.js samples and see what happens.
09-06-2012 03:19 AM - edited 09-06-2012 03:24 AM
Please checked and notified to my mistakes. This is an example of code that I created.
I think I've done well.
Maybe you could check if I ask and I'm doing is right or not