This is my first attempt at using Lawnchair. I was able to get a simple save/get example working, but the get only seems to work as long as it is within the same application launch. On subsequent app launches, it fails to find the object I have previously saved, so it appears it is not persistent.
I understand that 'DOM' is the default adapter for Lawnchair, but I was under the impression that DOM storage was persistent. Any ideas as to why it is not working for me? I have tested this on a Win7 machine running Chrome, and also on an Android device using PhoneGap. Again, it works within the scope of a single app launch, but the objects stored do not persist in subsequent app launches. My code is below. To test the Get on subsequent launches, I simply commented out the instantiation and save parts.
UPDATE: I attempted to use the Google Gears sqlite adapter, but when debugging, it got hung up on the first line where I instantiate, and never moved past that point. This all seems so simple, yet can't actually get it to work. What gives?
new Lawnchair({
adapter: "dom",
name: "ce-app-db"
}, function () {
this.nuke();
});
Lawnchair({ name: 'ce-app-db' }, function () {
alert('storage open - save');
this.save({ key: 'insps', value: msg });
});
Lawnchair({ name: 'ce-app-db' }, function () {
alert('storage open - get');
this.get('insps', function (obj) {
if (obj) {
var index = 0;
$.each(obj.value, function (i, item) {
if (item != null) {
index++;
}
});
alert(index + ' cases found');
}
else {
alert('cases not found');
}
});
});