I ran into a nasty problem with Lawnchair (0.6.1). I want to have 2 globally accessible collections/Lawnchairs, both with the webkit-sqlite adapter. This is how I declare them, right after loading Lawnchair and the adapter:
var clientStore = Lawnchair({name: 'clients'}, function () {});
var companyStore = Lawnchair({name: 'companies'}, function () {});
// other global variables
...
In Safari and Chrome on my desktop everything is smooth sailing, same for my iPad and other iOS devices in the emulator using Phonegap (3.0.0). No problems at all, both databases show up in the web inspector and in Weinre. I can use them in any of JQuery Mobile events (version 1.3.2 and 1.4.0 beta). Manually checking the database objects in Weinre confirms that they are indeed using the webkit-sqlite adapter.
But if run the Phonegap app on Android, only the clientStore
is accessible and usable. Trying to access the companyStore
gives me the following error:
companyStore.all(function (allEntries) {
console.log(allEntries);
...
> TypeError: Cannot call method 'all' of undefined
The only database that shows up in Weinre on the Android device is the clients
database. Manually initializing the companies
database from the Weinre inspector console after everything loaded up doesn't show any effect on the list of databases on the 'Resources' tab or change anything else (except for the above error visually disappearing).
Trying to access the 'undefined' companyStore
programmatically, say when someone switches to a page where all the companies shall be listed, 'crashes' the UI on the Android device. Nothing even gets printed on the console anymore after that. As said, all other platforms work just fine.
Am I just doing something stupidly wrong or did I encounter a bug/feature?
Thanks a ton for the help, this one is driving me up the wall :(.
Edit: using the standard DOM adapter works for me on every platform so far. I guess I'll stick to that one for now. In case someone ran into the same problem, here's how to explicitly use the DOM adapter:
var clientStore = Lawnchair({name: 'clients', adapter: 'dom'}, function () {});
var companyStore = Lawnchair({name: 'companies', adapter: 'dom'}, function () {});