ranjjose
ranjjose

Reputation: 2148

Updating/Downloading resource files dynamically in a phonegap Application

We are developing an employee engagement platform using phonegap, jquery, Django & mongodb. The admin module has the feature to create forms (A form creation module; something in the lines of php forms). These forms will be then used by other users for various purposes. I can create html content at the time of form creation itself and store it in database and then access it whenever required. This will obviously be a slower approach where in the entire form (that is the html content)comes from the server through the network.

Do we have any alternate approach where in say, when the application starts, it downloads all forms into your phone hence improving the speed at the time of accessing the form as now it comes from the device itself. Will the Phonegap File System API be of any help? Is there any other approach for achieving this? Thanks!

Upvotes: 2

Views: 792

Answers (1)

Tom Clarkson
Tom Clarkson

Reputation: 16174

Running an ajax request on app startup to download any forms not already downloaded is straightforward enough, and the filesystem api is an appropriate way to store them. I use a custom downloader plugin that handles both download and storage natively, but that's because my downloads are over 100MB - downloading into the browser first with a regular xhr should be fine for a typical web form.

The www directory is read only, so you can't save them there, but you can load pages from any folder in your app - as long as you are careful about any absolute urls in the form, there shouldn't be any difference between the downloaded forms and those bundled with the app.

Upvotes: 1

Related Questions