Skip to content

Commit 48f5a51

Browse files
committed
Fix for overwriting actions (doesn't fix overcount of subgoals)
1 parent 76baf52 commit 48f5a51

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/saveState.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ $( window ).unload(function() {
313313

314314
//Happens after refresh
315315
//confused about when this happens exactly
316+
317+
// TODO: Refactoring. This function contains code that exists elsewhere (see addToSandwich). Is it wise to have
318+
// buttons within an each() loop?
316319
function reloadSandwich () {
317320
console.log("Reloading sandwich menu...");
318321
var sidebarHTML = localStorage.getItem('sidebarHTML');
@@ -327,9 +330,14 @@ function reloadSandwich () {
327330
if (currId.length == 1) {
328331
//It's a subgoal
329332
//console.log("subgoal");
330-
sidebarBody().find("#sideSubgoal" + currId).unbind( "click" ).click(function(){
333+
sidebarBody().find("#sideSubgoal" + currId).unbind( "click" ).click(function(){
334+
var subArr = getSubgoalArrayFromLocal(); // in case something changes before the button is clicked
335+
// do not enter drawSubgoal with a different id until the current subgoal is saved
336+
if (statusIsTrue("gotSubgoalQuestions") || currId == subArr.length){
331337
drawSubgoal(currId);
332-
});
338+
}
339+
sideSubgoalExpandy(currId, 0);
340+
});
333341
//todo: add collapse onclick function here.
334342
}
335343

0 commit comments

Comments
 (0)