X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FProblems.vue;h=3b53a1a0c7ed05da7cd2e526ae216ce17f969a9c;hb=b1e46b33d78bdf144a5603f82a6907901763abb9;hp=ef05e12133b435c030590b1605e88049a1711b5f;hpb=e57c4de4148d43e7635e09adcde4e56585aea303;p=vchess.git diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue index ef05e121..3b53a1a0 100644 --- a/client/src/views/Problems.vue +++ b/client/src/views/Problems.vue @@ -97,6 +97,7 @@ main td {{ firstChars(p.instruction) }} td {{ p.id }} BaseGame( + ref="basegame" v-if="showOne" :game="game" ) @@ -162,7 +163,7 @@ export default { }); const showOneIfPid = () => { const pid = this.$route.query["id"]; - if (pid) this.showProblem(this.problems.find(p => p.id == pid)); + if (!!pid) this.showProblem(this.problems.find(p => p.id == pid)); }; if (Object.keys(names).length > 0) { ajax( @@ -188,8 +189,7 @@ export default { ); }, mounted: function() { - document - .getElementById("newprobDiv") + document.getElementById("newprobDiv") .addEventListener("click", processModalClick); }, watch: { @@ -201,7 +201,7 @@ export default { }, $route: function(to) { const pid = to.query["id"]; - if (pid) this.showProblem(this.problems.find(p => p.id == pid)); + if (!!pid) this.showProblem(this.problems.find(p => p.id == pid)); else this.showOne = false; } }, @@ -299,10 +299,13 @@ export default { // The FEN is already checked at this stage: this.game.vname = p.vname; this.game.mycolor = V.ParseFen(p.fen).turn; //diagram orientation + this.game.fenStart = p.fen; this.game.fen = p.fen; - this.$set(this.game, "fenStart", p.fen); - this.copyProblem(p, this.curproblem); this.showOne = true; + // $nextTick to be sure $refs["basegame"] exists + this.$nextTick(() => { + this.$refs["basegame"].re_setVariables(this.game); }); + this.copyProblem(p, this.curproblem); }); }, gotoPrevNext: function(e, prob, dir) {