From 88f02a05acba07b7be693faf7972710eb9950959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Volds=C3=A6ter?= <ole.voldsater@uib.no> Date: Fri, 28 Feb 2020 11:08:12 +0100 Subject: [PATCH] =?UTF-8?q?unng=C3=A5=20=C3=A5=20laste=20artikkel=20p?= =?UTF-8?q?=C3=A5=20nytt=20n=C3=A5r=20vi=20linker=20til=20annen=20def.=20i?= =?UTF-8?q?=20samme=20art.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/App.vue b/src/App.vue index 8b6988a7..04067e31 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,7 +15,7 @@ </header> <img id="spinner" :class="waiting ? 'show' : 'hide'" src="./assets/spinner.gif" alt="Venter på innhold" /> <SearchResults :hits="search_results" :lang="lang" @search-hit-click="search_hit_click" /> - <Article :article="article" @article-click="article_link_click" /> + <Article :key="article_key" :article="article" @article-click="article_link_click" /> </main> </template> @@ -41,6 +41,7 @@ export default { name: 'app', data: function() { return { + article_key: 0, search_results: [], lang: 'nob', waiting: true, @@ -101,14 +102,18 @@ export default { }, article_link_click: function(item) { var self = this - self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} - self.waiting = true - axios.get(api_endpoint + '/' + self.lang + '/' + item.article_id) - .then(function(response){ - self.article = response.data._source - self.waiting = false - history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') - }) + if (this.article.article_id == item.article_id){ + this.article_key++ + }else{ + self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} + self.waiting = true + axios.get(api_endpoint + '/' + self.lang + '/' + item.article_id) + .then(function(response){ + self.article = response.data._source + self.waiting = false + history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') + }) + } }, search_hit_click: function(article){ this.search_results = [] -- GitLab