I have a JS file with indexedDB functions, like this:
// Get all object stores from IndexedDB
mydb.indexedDB.getObjStores = function() {
var db = mydb.indexedDB.db;
return db.objectStoreNames;
};
I call this function from another JS file, where I need the names of the object stores to do something with them like populate a combo:
function doSomething(){
var arr = mydb.indexedDB.getObjStores();
for (var i=0; i<arr.length;i++) {
document.getElementById('mycombo').options[i] = new Option (arr[i], i);
}
}
Depending on the browser, the combo is empty, although I can get the lenght of the array (weird). I think the problem is that asynchronus thing that is killing me… I thought that using something like addEventListener was a good idea (When can I tell that I have opened a connection in indexedDB?), but this indexedDB call has no onsuccess event. It works fine with Chrome and Firefox, but not in a PDA browser e.g.
How can I wait for this? Is that the problem?
Thank you!
Problem solved. The indexedDB specification in this browser is a little bit different: getObjStores() returns an object with some arrays, one of them the list of object stores. So I was retrieving unexisting data, because I was expecting a DOMStringList. An “stupid” error in a very particular case. Thank you.