How to overwrite existing scopes using angular select - javascript

I'm making a system that allows for drafts in my ionic and angular app.
Some values are automatically set when opening the page, now i try to overwrite them using the draft data like this.
<select name="" ng-model="draft" ng-change="loadDraft(draft);">
<option ng-repeat="draft in drafts" value="{{draft.info}}">{{draft.info.Ordernumber}}</option>
</select>
And my controller code:
$scope.loadDraft = function(draft) {
if(draft){
var parsed = JSON.parse(draft);
vm.infoFactory.ArrayInfo = parsed;
$scope.info = parsed;
}else {
console.log("oops");
}
}
Problem is that it only loads the "new" values and does not overwrite things like the order number that are automatically set on page load.
How do i force all values to update to the loaded array information.
--- edit ---
I just found out that when setting the initial scope by hand it does overwrite the value just fine. Problem is probably in the way i set the scopes on page load
this does overwrite fine.
vm.infoFactory.ArrayInfo.Ordernumber = "2017-33";
when adding this piece of code it doesnt
if(vm.infoFactory.ArrayInfo.OrdernumberSet == true){
console.log("all set");
}
else{
console.log("New Date");
var date = new Date();
vm.infoFactory.ArrayInfo.currentYear = date.getFullYear();
var Ordervalue = firebase.database().ref("/savednumbers/" + vm.infoFactory.ArrayInfo.currentYear);
$scope.$watch("info", function(newValue, oldValue) {
Ordervalue.on("value", function(snapshot) {
var data = snapshot.val();
vm.infoFactory.ArrayInfo.Ordervalue = data.last_number;
vm.infoFactory.ArrayInfo.Ordervalue++;
vm.infoFactory.ArrayInfo.Ordernumber = vm.infoFactory.ArrayInfo.currentYear + "-" + vm.infoFactory.ArrayInfo.Ordervalue;
});
});
vm.infoFactory.ArrayInfo.OrdernumberSet = true;
}
probably should open a new question for this?
--- edit ---
The value is okay on "draft" but after my JSON.parse it takes the new value

if you want to access the whole object in ng-change function then assign the whole object to the value
<option ng-repeat="draft in drafts" value="{{draft}}">{{draft.info.Ordernumber}}</option>

Related

Doesn't add records into PouchDB when used same function over again

I'm trying to create a database with "users" and their data in it. Strangely it doesn't put() new variables in it when I try to for the third time. To do all this I create a local database dblocal and replicate this DB to the remote db called dbremote. At first I create a document with one variable.
function newuser() {
if (window.document.consent_form.consent_to_share.value) {
var id = "p" + Date.now() + "-" + Math.floor(Math.random() * 10000);
var dblocal = new PouchDB(id);
var consenttoshare = window.document.consent_form.consent_to_share.value;
document.cookie = id;
var dbremote = 'http://localhost:5984/experiment';
dblocal.put({
_id: id,
consent: consenttoshare
});
dblocal.replicate.to(dbremote, {live: true});
}
}
This all worked well, in another js file I'm trying to add a variable to the same document by executing the following function putdb(). Im doing this in the following way (as said in their documentation is the right way):
function putdb () {
if (document.cookie){
var id = document.cookie;
var loggedin = "True";
var dblocal = new PouchDB(id);
dblocal.get(id).then(function (doc) {
doc.loggedin = loggedin;
return dblocal.put(doc);
}).then(function () {
return dblocal.get(id);
}).then(function (doc) {
console.log(doc);
var dbremote = 'http://localhost:5984/experiment';
dblocal.replicate.to(dbremote, {live: true});
});
}
}
This succesfully added the variable loggedin to the document as I wanted. However upon trying to add information to this document for the third time (again in another js file), nothing happens. I used exactly the same approach as before but only use different variables.
function putdb (checked) {
if (document.cookie) {
var id = document.cookie;
var checkedlist = [];
for (i = 0; i < checked; i++) {
checkedlist.push($("input[type=checkbox]:checked")[i].value)
}
var playlistname = document.getElementById("playlistname").value;
var dblocal = new PouchDB(id);
dblocal.get(id).then(function (doc) {
doc.checkedlist = checkedlist;
doc.playlistname = playlistname;
return dblocal.put(doc);
}).then(function () {
return dblocal.get(id);
}).then(function (doc) {
console.log(doc);
var dbremote = 'http://localhost:5984/experiment';
dblocal.replicate.to(dbremote, {live: true});
});
}
}
I checked all variables, they are correct.
I tried plain text variables.
The script does run.
I tried to add information to the document the way I did the first time.
None of all this seems to add another variable to the document as I wanted in the last function. I think it has to do with the way pouchDB works which I don't know. help is much appreciated!
There are a number of problems in your code that results in bad usage of PouchDB, and may lead to problems.
First of all, it does not make a lot of sense to give your document the same id as the name of your database. Assuming you want a one database per user approach, there are two approaches you can follow.
Multiple document approach
You can instead make multiple documents within the same database with different id's. For instance, your 'consent' information may be stored like this:
var id = "p" + Date.now() + "-" + Math.floor(Math.random() * 10000);
let dblocal = new PouchDB(id);
document.cookie = id;
let dbremote = 'http://localhost:5984/experiment';
dblocal.put({
_id: "consent",
consent: window.document.consent_form.consent_to_share.value
});
dblocal.replicate.to(dbremote, {live: true});
While your playlist information is stored like this:
dblocal.put({
_id: "playlist",
name: playlistname,
itemsChecked: checkedlist
});
Single-document approach
The second option is to store a single document containing all the information you want to store that is associated to a user. In this approach you will want to fetch the existing document and update it when there is new information. Assuming you named your document global-state (i.e. replace "consent" in the first code snippet with "global-state"), the following code will update a document:
dblocal.get("global-state").then((doc)=>{
doc.loggedIn = true; // or change any other information you want
return dblocal.put(doc);
}).then((response)=>{
//handle response
}).catch((err)=>{
console.log(err);
});
Furthermore, you should only call the
dblocal.replicate.to(dbremote, {live: true});
function once because the 'live' option specifies that future changes will automatically be replicated to the remote database.

SharePoint 2013 get document library created by users in JavaScript

Hi I am trying to get all documents library only created by the logged users. With the following code I get also libraries which was not created from a user. Thank you.
function GetAllLibraries() {
var listCollection = lists.getEnumerator();
while (listCollection.moveNext()) {
var listName = listCollection.get_current().get_title('Title');
document.getElementById('leftDiv').innerHTML += "<b>" + listName + "<b/>" + "<br />";
}
}
Since you are utilizing SharePoint JavaScript API (a.k.a JSOM) it is a bit tricky since SP.List object does not expose Author property to determine who created this object. But the good news that Author property could be extracted from SP.List.schemaXml property as demonstrated below
Here is a complete example how to retrieve lists created by current user
var ctx = SP.ClientContext.get_current();
var allLists = ctx.get_web().get_lists();
var currentUser = ctx.get_web().get_currentUser();
ctx.load(allLists,'Include(SchemaXml)');
ctx.load(currentUser);
ctx.executeQueryAsync(
function(){
var lists = allLists.get_data().filter(function(list){
var listProperties = schemaXml2Json(list.get_schemaXml());
var listAuthorId = parseInt(listProperties.Author);
return listAuthorId == currentUser.get_id();
});
console.log("The amount of lists created by current user: " + lists.length);
},
logError);
}
function schemaXml2Json(schemaXml)
{
var jsonObject = {};
var schemaXmlDoc = $.parseXML(schemaXml);
$(schemaXmlDoc).find('List').each(function() {
$.each(this.attributes, function(i, attr){
jsonObject[attr.name] = attr.value;
});
});
return jsonObject;
}
function logError(sender,args){
console.log(args.get_message());
}
If you want to know who created list or library, you need to get property SPList.Author. As i know, you can't get it by JSOM.
My advice for you is to develop your own http hanlder with logic on server-side and call it by ajax. For example, you pass arguments into handler like web url (_spPageContextInfo.webAbsoluteUrl), current user login or id (_spPageContextInfo.userId), and in handler iterate lists on web, compare current user and list creator. Finally, return needed lists info.
Or just develop web part and do the same: iterate lists and compare it with SPContext.Current.Web.CurrentUser
UPDATE:
Example of c# code. You can put it in your web part or event handler. In this code we iterate all lists on SPWeb and save lists title created by current user.
private void GetLists()
{
using (SPSite site = new SPSite("{site_url}"))
{
using (SPWeb web = site.OpenWeb())
{
SPListCollection listCol = web.Lists;
List<string> currentUserLists = new List<string>();
foreach(SPList list in listCol)
{
if (list.Author.ID == SPContext.Current.Web.CurrentUser.ID)
{
currentUserLists.Add(list.Title);
}
}
}
}
}

Store Properties for a SharePoint-hosted app

I'm trying to figure of the best--or really any working way-- to store key/value pairs in a SharePoint hosted app. The pairs need to:
Be loaded on start up, if the settings exist, otherwise use defaults.
Be created on demand--i.e. a user can add a new setting in the UI, then I use that setting elsewhere in the code to make changes. For example a use a custom string of text as a list name instead of the app's default setting.
I've tried using the PropertyBag, but get an Access Denied error when trying to write to it.
I've also tried to use a list but had problems getting that technique to work correctly.
Does anyone have a suggestion of a good method and how it would be done. I'd be happy to revisit the techniques I've already attempted, if those are the best ways.
Keep in mind that this question should be restricted to things that work with a SharePoint-hosted app. That means that C#, and server-side code are out.
Here's the solution I ended up using--storing settings in a list in the hostweb of the app.
It's made up of a few functions seen below.
CreateSettingsList:
Create makes an ordinary list with the fields Title and Value, which I use to store a setting name and a value to be associated with it. This is called in the document ready function to ensure that a list has been created, and if one already has, it goes on and tries to read from it. If a list didn't exist before, I call a function to initialize default variable values in the list.
//___________________________________Create settings list________________________________________
function createSettingsList()
{
// Create a SharePoint list with the name that the user specifies.
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var hostContext = new SP.AppContextSite(currentContext, hostUrl);
var hostweb = hostContext.get_web();
var listCreationInfo = new SP.ListCreationInformation();
//title the list
listCreationInfo.set_title("PTOAppSettings");
//set the base type of the list
listCreationInfo.set_templateType(100); //generic list
listCreationInfo.set_description("A list for custom app settings. If you have uninstalled the Paid Time Off App with no intention of reinstalling, this list can be safely deleted.");
var lists = hostweb.get_lists();
//use the creation info to create the list
var newList = lists.add(listCreationInfo);
var fieldCollection = newList.get_fields();
//add extra fields (columns) to the list & any other info needed.
fieldCollection.addFieldAsXml('<Field Type="Text" DisplayName="Value" Name="Value" />', true, SP.AddFieldOptions.AddToDefaultContentType);
newList.update();
currentContext.load(fieldCollection);
currentContext.load(newList);
currentContext.executeQueryAsync(onSettingsListCreationSuccess, onSettingsListCreationFail);
}
function onSettingsListCreationSuccess(){
//All is well.
initializeSettings();
}
function onSettingsListCreationFail(sender, args) {
//alert("We didn't create the list. Here's why: " + args.get_message());
//If a list already exists, we expect the creation to fail, and instead try to read from the existing one.
getSetting("VAR_CCEmail");
}
Initialize:
Initialize creates new list items for the variables that I may be storing in the future. I set their value to "" or null if they're not being used.
//___________________________________Initialize setting(s)________________________________________
function initializeSettings()
{
//Get info to access host web
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var hostContext = new SP.AppContextSite(currentContext, hostUrl);
var hostweb = hostContext.get_web();
//Get list in host web
var lstObject = hostweb.get_lists().getByTitle("PTOAppSettings");
//Prepare an object to add a new list item.
var listItemCreationInfo = new SP.ListItemCreationInformation();
var newItem = lstObject.addItem(listItemCreationInfo);
//Create item. You should repeat this for all the settings you want to track.
newItem.set_item('Title', "VAR_CCEmail");
newItem.set_item('Value', "");
//Write this new item to the list
newItem.update();
currentContext.executeQueryAsync(onListItemSuccess, onListItemFailure);
function onListItemSuccess() {
//Load customizations, if any exist
getSetting("VAR_CCEmail");
}
function onListItemFailure(sender, args) {
bootbox.dialog({
title: "Something went wrong!",
message: "We were unable to initialize the app settings! Here's what we know about the problem: " + args.get_message() + '\n' + args.get_stackTrace(),
buttons: {
success:{
label: "Ok"
}
}
});
}
}
Set:
Set is a fairly straightforward function that accepts a setting name and a value and allows you to update the value stored in a given variable.
//___________________________________Set setting________________________________________
function setSetting(setting, value){
//Get info to access host web
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var hostContext = new SP.AppContextSite(currentContext, hostUrl);
var hostweb = hostContext.get_web();
//Get list in host web
var list = hostweb.get_lists().getByTitle("PTOAppSettings");
//A caml query get the appropriate setting
var queryXml = "<View><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + setting + "</Value></Eq></Where></Query></View>"
var query = new SP.CamlQuery();
query.set_viewXml(queryXml);
var items = list.getItems(query);
currentContext.load(items);
currentContext.executeQueryAsync(onListItemSuccess, onListItemFailure);
function onListItemSuccess() {
//looking up a specific setting should only return one item in the array.
var item = items.getItemAtIndex(0);
//update the value for the item.
item.set_item("Value", value);
item.update();
}
function onListItemFailure(sender, args) {
bootbox.dialog({
title: "Something went wrong!",
message: "We were unable to set app settings! Here's what we know about the problem: " + args.get_message() + '\n' + args.get_stackTrace(),
buttons: {
success:{
label: "Ok"
}
}
});
}
}
Get:
Get reads the list, finds the setting that you specified, and then determines if the Value associated with that setting "" or null or if it is an actual value. If it is an actual value, I write the value to the global variable that the program uses to do things with that setting.
//___________________________________Get setting________________________________________
function getSetting(setting) {
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var hostContext = new SP.AppContextSite(currentContext, hostUrl);
var hostweb = hostContext.get_web();
var list = hostweb.get_lists().getByTitle("PTOAppSettings");
//A caml query to get manager name for the record where user is equal to current user.
var queryXml = "<View><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + setting + "</Value></Eq></Where></Query></View>"
var query = new SP.CamlQuery();
query.set_viewXml(queryXml);
var items = list.getItems(query);
currentContext.load(items);
currentContext.executeQueryAsync(
function() //on success.
{
//get first (and only) item.
var item = items.getItemAtIndex(0);
var value = item.get_item("Value");
//If the property is empty it hasn't been set.
if (value === "" || value === null){
//Return null to the appropriate global variable. Not all of the settings in this switch are implemented in the program yet, but may be later.
switch(setting) {
case "VAR_PaidTimeOff":
paidTimeOffListName = "";
break;
case "VAR_Contacts":
contactsListName = "";
break;
case "VAR_CCEmail":
carbonCopyEmail = "";
break;
}
}
else
{
//Return the value. Not all of the settings in this switch are implemented in the program yet, but may be later.
switch(setting) {
case "VAR_PaidTimeOff":
paidTimeOffListName = value;
break;
case "VAR_Contacts":
contactsListName = value;
break;
case "VAR_CCEmail":
carbonCopyEmail = value;
break;
}
}
},
function(sender,args){
bootbox.dialog({
title: "Something went wrong!",
message: "We were unable to get app settings! Here's what we know about the problem: " + args.get_message() + '\n' + args.get_stackTrace(),
buttons: {
success:{
label: "Ok"
}
}
});
});
}
This could be expanded to include other functions to do other special tasks, for example you could make a "createSetting" function that would allow you to add new settings on the fly (one of the requirements I mentioned in my initial question). In my case, initializing a set group of settings fulfilled my needs, but other may want a way to write more.

Cant get the current id of a data from local Storage using jquery

I am working on an app to store data offline. My problem is when I try to retrieve the data from local storage for update/edit, it keeps calling only the id of the first item, and not calling the id of the data in view.
Please what am I doing wrong?
Here is my code for loading employees:
// load cases from localStorage
var employees;
if (localStorage.getItem('employees')) {
employees = JSON.parse(localStorage.getItem('employees'));
} else {
// If no cases, create and save them
employees = [];
// offling storing of our cases
localStorage.setItem('employees', JSON.stringify(employees));
}
// show case listing in list view page
var showEmployees = function () {
//erase existing content
$('#employee_list').html('');
//insert each employee
for (var i = 0; i<employees.length; i++) {
addEmployees(employees[i]);
}
};
Here is my code to add an employee to list view:
//add an eliment to list view
var addEmployees = function (empData) {
//HTML content of one list element
var listElementHTML = '<li><a class="employee_list" ui-btn ui-btn-e ui-btn-icon-right ui-icon-carat-r" data-transition="fade" data-split-icon="delete" href="#item'+empData.id+'">' + empData.employeename + '<br> ' + empData.dateofbirth + '</br></a></li>';
//appending the HTML code to list view
$('#employee_list').append(listElementHTML);
};
Here is my code for Edit function:
//User input to edit form
$('#edit_employee_page').on('click' , function () {
var editEmployee = JSON.stringify({
id: employees.length+1,
employeeno: $('#employeeno').val(),
employeename:$('#employeename').val(),
stateoforigine:$('#stateoforigine').val(),
employeephone: $('#employeephone').val(),
dateofbirth:$('#dateofbirth').val()
});
//Alter the slected data
localStorage.setItem("employees", JSON.stringify(employees));
return true;
});
for (var i in employees) {
var id = JSON.parse(localStorage.getItem(employees[i]));
}
Here is my code for the Edit button:
//register Edit button
$('.edit_button').live('click', function (e) {
alert('I was Cliked!');
e.stopPropagation();
$.each(employees, function(a, b) {
//if(b.id == employees[i]){
$('#id').val(b.id);
$('#employeeno').val(b.employeeno);
$('#employeename').val(b.employeename);
$("#stateoforigine").val(i.stateoforigine);
$('#employeephone').val(b.employeephone);
$('#dateofbirth').val(b.dateofbirth);
$("#id").attr("readonly","readonly");
$('#employeeno').focus();
$.mobile.changePage('#edit_employee_page');
return false;
//}
});
});
Here is my local Storage:
[
{"id":1,
"employeeno":"DEF/234/20014",
"employeename":"Bill Gates",
"stateoforigine":"Osun",
"employeephone":"080765432",
"dateofbirth":"12/11/1965"},
{"id":2,
"employeeno":"DEF/234/20014",
"employeename":"Bill Gates",
"stateoforigine":"Osun",
"employeephone":"080765432",
"dateofbirth":"12/11/1966"},
{"id":3,
"employeeno":"DEF/234/20014",
"employeename":"Bill Gates",
"stateoforigine":"Osun",
"employeephone":"080765432",
"dateofbirth":"12/11/1966"},
{"id":4,
"employeeno":"DAST/003/2003",
"employeename":"Gold Base",
"stateoforigine":"",
"employeephone":"",
"dateofbirth":"12/03/1986"}
]
Thanks for helping me out
The way you are storing your employees into localStorage is correct, but the way you are getting them out is incorrect. You stored your employees by stating:
localStorage.setItem("employees", JSON.stringify(employees));
So, in order to retrieve them, you must use:
var employees = JSON.parse(localStorage.getItem("employees"));
You see, you stored the data as a string with a key of "employees"; therefore, you can only retrieve it by that key. Since all data stored in localStorage is saved as a string, you must use JSON.parse() to convert the data back into an object - an array in this case. Then you can iterate over your employees.
Update:
You should be running this code as soon as the page is rendered (see below). I'm not sure how you're doing that - if you're using an IIFE or jQuery's document.ready() function. I don't think it's necessary to store an empty array into localStorage if none were loaded initially, so, I took your else clause out.
var employees = [];
if (localStorage.getItem('employees') !== null) {
employees = JSON.parse(localStorage.getItem('employees'));
}
Debug this line-by-line when it runs and make positive your employees variable contains data. If it doesn't contain data, well then, there's nothing to edit.
If, however, there is data, then execute your showEmployees() function. Oddly, I'm not seeing in your code where you actually call this. Is it bound to a button or action in your UI? Also, what is that for loop doing after your $('#edit_employee_page') click event function? It's trying to read data from localStorage improperly and it does nothing.
I think if you simply stepped through your code one line at a time using breakpoints and desk-checking your inputs/outputs you'd find out where you're going wrong.
It also appears that there's a disconnect in your code. May be you left out some lines; you define a string editEmployee but out of the blues you store JSON.stringify(employees) whereas employees is not defined in your code:
$('#edit_employee_page').on('click' , function(){
var editEmployee = JSON.stringify({
id: employees.length+1,
//........
});
//Alter the slected data
localStorage.setItem("employees", JSON.stringify(employees));
return true;
});
I had a similar task to do . I did it this way.
I passed the dynamic Id to be passed as an id attribute
id="'+empData.id+'"
and then inside the
$('.edit_button').live('click', function (e) {
alert('I was Cliked!');
var empId=$(this).attr('id');
rest of the code is same.

Chrome Extension with Database API interface

I want to update a div with a list of anchors that I generate from a local database in chrome. It's pretty simple stuff, but as soon as I try to add the data to the main.js file via a callback everything suddenly becomes undefined. Or the array length is set to 0. ( When it's really 18. )
Initially, I tried to install it into a new array and pass it back that way.
Is there a setting that I need to specify in the chrome manifest.json in order to allow for communication with the database API? I've checked, but all I've been able to find was 'unlimited storage'
The code is as follows:
window.main = {};
window.main.classes = {};
(function(awe){
awe.Data = function(opts){
opts = opts || new Object();
return this.init(opts);
};
awe.Data.prototype = {
init:function(opts){
var self = this;
self.modified = true;
var db = self.db = openDatabase("buddy","1.0","LocalDatabase",200000);
db.transaction(function(tx){
tx.executeSql("CREATE TABLE IF NOT EXISTS listing ( name TEXT UNIQUE, url TEXT UNIQUE)",[],function(tx,rs){
$.each(window.rr,function(index,item){
var i = "INSERT INTO listing (name,url)VALUES('"+item.name+"','"+item.url+"')";
tx.executeSql(i,[],null,null);
});
},function(tx,error){
});
});
self._load()
return this;
},
add:function(item){
var self = this;
self.modified = true;
self.db.transaction(function(tx){
tx.executeSql("INSERT INTO listing (name,url)VALUES(?,?)",[item.name,item.url],function(tx,rs){
//console.log('success',tx,rs)
},function(tx,error){
//console.log('error',error)
})
});
self._load()
},
remove:function(item){
var self = this;
self.modified = true;
self.db.transaction(function(tx){
tx.executeSql("DELETE FROM listing where name='"+item.name+"'",[],function(tx,rs){
//console.log('success',tx,rs)
},function(tx,error){
//console.log('error',tx,error);
});
});
self._load()
},
_load:function(callback){
var self = this;
if(!self.modified)
return;
self.data = new Array();
self.db.transaction(function(tx){
tx.executeSql('SELECT name,url FROM listing',[],function(tx,rs){
console.log(callback)
for(var i = 0; i<rs.rows.length;i++)
{
callback(rs.rows.item(i).name,rs.rows.item(i).url)
// var row = rs.rows.item(i)
// var n = new Object()
// n['name'] = row['name'];
// n['url'] = row['url'];
}
},function(tx,error){
//console.log('error',tx,error)
})
})
self.modified = false
},
all:function(cb){
this._load(cb)
},
toString:function(){
return 'main.Database'
}
}
})(window.main.classes);
And the code to update the list.
this.database.all(function(name,url){
console.log('name','url')
console.log(name,url)
var data = []
$.each(data,function(index,item){
try{
var node = $('<div > '+item.name + '</div>');
self.content.append(node);
node.unbind();
node.bind('click',function(evt){
var t = $(evt.target).attr('href');
chrome.tabs.create({
"url":t
},function(evt){
self._tab_index = evt.index
});
});
}catch(e){
console.log(e)
}
})
});
From looking at your code above, I notice you are executing "self._load()" at the end of each function in your API. The HTML5 SQL Database is asynchronous, you can never guarantee the result. In this case, I would assume the result will always be 0 or random because it will be a race condition.
I have done something similar in my fb-exporter extension, feel free to see how I have done it https://github.com/mohamedmansour/fb-exporter/blob/master/js/database.js
To solve a problem like this, did you check the Web Inspector and see if any errors occurs in the background page. I assume this is all in a background page eh? Try to see if any error occurs, if not, I believe your encountering a race condition. Just move the load within the callback and it should properly call the load.
Regarding your first question with the unlimited storage manifest attribute, you don't need it for this case, that shouldn't be the issue. The limit of web databases is 5MB (last I recall, it might have changed), if your using a lot of data manipulation, then you use that attribute.
Just make sure you can guarantee the this.database.all is running after the database has been initialized.

Categories

Resources