Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/App.vue
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | export default { | ||||
} | } | ||||
axios.get('/content/faq' + page, { ignoreErrors: true }) | axios.get('/content/faq' + page, { ignoreErrors: true }) | ||||
.then(response => { | .then(response => { | ||||
const result = response.data.faq | const result = response.data.faq | ||||
$('#faq').remove() | $('#faq').remove() | ||||
if (result && result.length) { | if (result && result.length) { | ||||
let faq = $('<div id="faq" class="faq mt-3"><h5>' + this.$t('app.faq') + '</h5><ul class="pl-4"></ul></div>') | let faq = $('<div id="faq" class="faq mt-3"><h5>' + this.$t('app.faq') + '</h5><ul class="pl-4"></ul></div>') | ||||
let list = [] | let list = $([]) | ||||
result.forEach(item => { | result.forEach(item => { | ||||
list.push($('<li>').append($('<a>').attr('href', item.href).text(item.title))) | let li = $('<li>').append($('<a>').attr('href', item.href).text(item.title)) | ||||
// Handle internal links with the vue-router | // Handle internal links with the vue-router | ||||
if (item.href.charAt(0) == '/') { | if (item.href.charAt(0) == '/') { | ||||
list[list.length-1].find('a').on('click', event => { | li.find('a').on('click', event => { | ||||
event.preventDefault() | event.preventDefault() | ||||
this.$router.push(item.href) | this.$router.push(item.href) | ||||
}) | }) | ||||
} | } | ||||
list = list.add(li) | |||||
}) | }) | ||||
faq.find('ul').append(list) | faq.find('ul').append(list) | ||||
$(this.$el).append(faq) | $(this.$el).append(faq) | ||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
routerReload() { | routerReload() { | ||||
// Together with beforeRouteUpdate even on a route component | // Together with beforeRouteUpdate even on a route component | ||||
// allows us to force reload the component. So it is possible | // allows us to force reload the component. So it is possible | ||||
// to jump from/to page that uses currently loaded component. | // to jump from/to page that uses currently loaded component. | ||||
this.routerReloading = true | this.routerReloading = true | ||||
this.$nextTick().then(() => { | this.$nextTick().then(() => { | ||||
this.routerReloading = false | this.routerReloading = false | ||||
}) | }) | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |