Skip to content
Snippets Groups Projects
Commit 88f02a05 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

unngå å laste artikkel på nytt når vi linker til annen def. i samme art.

parent f2b4f048
No related branches found
No related tags found
No related merge requests found
......@@ -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 = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment