03-01-2013 01:21 AM
I am developing an app using Blackberry webworks 10 for Phone along with bbui.js.
I have a list of cities. On click of each city I list few images from the webservice.
My problem is each time I click on the same city it downloads from the webservice which takes some time.
Is there any particular way of caching the images where in the next time I click on the same city it can load the images real quick?
What is the right way to achieve this?
Any help would be really appreciated.
Thanks in advance.
03-01-2013 12:57 PM
As long as your JS variable stays in scope, the image should remain in the cache. However, you'll want to ensure you clean up your variables once you are done otherwise it will grow the memory usage. Usually setting the variable to null will clean it up.
03-02-2013 02:39 AM
But I have a problem here.
In screen A for ex. I list few cities say some 50 cities.
In screen B depending on the city selected in screen A(city is passed as a query string)
I display the images along with data related to that particular image from the response.
How would I pefetch in this scenario?
03-04-2013 08:40 AM
I'm not sure I understand. As long as you have a URL you should be able to pre-fetch.
Can you explain your scenario further?
03-05-2013 06:10 AM
Let me explain the scenario from the begining.
I have screen A. In screen A I make an ajax call
I display the cities obtained from the response on Screen A. ex: Chicago, Dallas, SanDiego......
Now onclick of any one particular city, Screen B is displayed.
In screen B again I make an ajax call :
Depending on the response I dispaly the images .
The problem is, as I am dispalying n number of images in screen B it is taking lot of time. I want to get rid of this issue.
You mentioned to prefetch but how would I know which city will be selected by the user in screen A?
Probably I can prefetch Screen A as it will result in the same data always i.e by default it will just display the cities.
I hope I am clear now.
Please help me out.
I also wanted to understand that is there any option to use dropdown of BBui.js as an autocomplete to search from the dropdown list?
03-05-2013 11:21 AM
There isn't a dropdown autocomplete in bbUI.js
In your situation you're not going to likely know which one the user is picking..
The only savings you could do is when they view screen B pre-fetch the images so that if they go back and then into screen B again they are cached.
Although this could also be handled by setting the cache headers on the images and wouldn't require client side coding.