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

fikset noen routing-feil

parent 8f224faa
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ window.onpopstate = function (event) { ...@@ -27,6 +27,7 @@ window.onpopstate = function (event) {
if (event.state) { if (event.state) {
app.__vue__._data.article = event.state.article app.__vue__._data.article = event.state.article
app.__vue__._data.search_results = event.state.search_results app.__vue__._data.search_results = event.state.search_results
app.__vue__._data.lang = event.state.lang
} }
} }
...@@ -80,17 +81,19 @@ export default { ...@@ -80,17 +81,19 @@ export default {
this.$refs.search.value = '' this.$refs.search.value = ''
document.activeElement.blur() document.activeElement.blur()
if(event._source){ if(event._source){
this.$router.push('/' + this.lang + '/' + event._id)
history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang}, '')
this.search_results = [] this.search_results = []
this.article = event._source this.article = event._source
history.pushState({article: this.article, search_results: this.search_results}, '', '/' + this.lang + '/' + event._id)
}else{ }else{
var self = this var self = this
self.waiting = true self.waiting = true
self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}}
axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q) axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q)
.then(function(response){ .then(function(response){
self.$router.push('/' + self.lang + '/_search?q=' + event.q)
history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
self.search_results = response.data.hits.hits self.search_results = response.data.hits.hits
history.pushState({article: self.article, search_results: self.search_results}, '', '/' + self.lang + '/_search?q=' + event.q)
self.waiting = false self.waiting = false
}) })
} }
...@@ -102,13 +105,13 @@ export default { ...@@ -102,13 +105,13 @@ export default {
.then(function(response){ .then(function(response){
self.article = response.data._source self.article = response.data._source
self.waiting = false self.waiting = false
history.replaceState({article: self.article, search_results: self.search_results}, '') history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
}) })
}, },
search_hit_click: function(article){ search_hit_click: function(article){
this.search_results = [] this.search_results = []
this.article = article this.article = article
history.replaceState({article: article, search_results: []}, '') history.replaceState({article: article, search_results: [], lang: this.lang}, '')
} }
}, },
mounted: function(){ mounted: function(){
...@@ -126,7 +129,7 @@ export default { ...@@ -126,7 +129,7 @@ export default {
.then(function(response){ .then(function(response){
self.article = response.data._source self.article = response.data._source
self.waiting = false self.waiting = false
history.replaceState({article: self.article, search_results: self.search_results}, '') history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
}) })
} }
else { else {
......
<template> <template>
<li class="sub_article"> <li class="sub_article">
<span class="sub_article_header"> <span class="sub_article_header">
<router-link :to="'' + body.article_id" @click.native="article_link_click(body)"> <router-link :to="'./' + body.article_id" @click.native="article_link_click(body)">
{{body.lemmas[0]}} {{body.lemmas[0]}}
</router-link> </router-link>
</span> </span>
......
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