I have a huge array called newCombs
when I call store.put(game)
the tab turns white and is gone in chrome task manager. Basically the process just stops and it fails to store the array
var trans = this.db.transaction('Games', 'readwrite');
var store = trans.objectStore('Games');
store.get(new Date().toLocaleDateString() + ' ' + prize.value).onsuccess = function() {
var game = this.result;
game.combs = game.combs.concat(newCombs); //I'm appending to the game.combs array which is empty when I first run it (when it also crashes)
store.put(game);
}
trans.oncomplete = function(evt) {
arrLength = 0;
newCombs = [];
}
This is what game
is equal to:
game = {
name: new Date().toLocaleDateString() + ' ' + prize.value,
date: new Date().toLocaleDateString(),
prize: prize.value,
playerData: [...],
points: {...}
}
The above part is a method of an object so this
is not the window object everything works fine until the code hits the line with: store.put(game);
the page just crashes.
this
is what you think it is?this
is not preserved inside anonymous functions and you're using it inside an anonymous function in theonsuccess
event handler. Did you try logging thegame
variable?this
is correct in it's context it works fine I get the correctgame
object. Read the comment (just in case you ever get this problem) on the bottom I figured out my problem, I don't want to copy paste it here.