I am using JQuery IndexedDB Plugin available here http://nparashuram.com/jquery-indexeddb/ . Following is the code that I iterate over the objectstore project_created. When I run this code ss is alerted before objectstore task_created is iterated. But logically, ss should be alerted only after objectstore task_created is iterated.
$.indexedDB("sl_task_tracker").objectStore("project_created").each(function(elem){
var count_tasks=0;
$.indexedDB("sl_task_tracker").objectStore("task_created").each(function(item){
if(item.value.project_id==elem.key)
count_tasks++;
});
alert("ss");
});
});
I believe this is because IndexedDB uses an aynchronous API. Everything related to IndexedDB is done in “another thread” in order to not block the main thread (so that the web site won’t appear to be fixed).
I don’t know about this plugin, but you should check if you can pass a “onSuccess” function to your task, this way you can specify what’s gonna happen once the task has been completed.
For more information about the plugin you’re using, you can always ask the dev on his github page : https://github.com/axemclion/jquery-indexeddb
(Sorry about my bad technical english, feel free to edit in a much more understandable language)