Fixed feedback widget not shown when using instant loading

This commit is contained in:
squidfunk
2022-08-27 11:39:17 +02:00
parent 86378edb60
commit 46d06c1c1d
2 changed files with 22 additions and 16 deletions

View File

@@ -49,8 +49,12 @@
}
/* Set up feedback, i.e. "Was this page helpful?" */
if (document.forms.feedback) {
document$.subscribe(function() {
var feedback = document.forms.feedback
if (typeof feedback === "undefined")
return
/* Send feedback to Google Analytics */
for (var button of feedback.querySelectorAll("[type=submit]")) {
button.addEventListener("click", function(ev) {
ev.preventDefault()
@@ -72,15 +76,14 @@
/* Show feedback */
feedback.hidden = false
}
}
})
/* Send page view on location change */
if (typeof location$ !== "undefined")
location$.subscribe(function(url) {
gtag("config", "{{ property }}", {
page_path: url.pathname
})
location$.subscribe(function(url) {
gtag("config", "{{ property }}", {
page_path: url.pathname
})
})
})
/* Create script tag */
@@ -123,10 +126,14 @@
}
/* Set up feedback, i.e. "Was this page helpful?" */
if (document.forms.feedback) {
document$.subscribe(function() {
var feedback = document.forms.feedback
if (typeof feedback === "undefined")
return
/* Send feedback to Google Analytics */
for (var button of feedback.querySelectorAll("[type=submit]")) {
button.addEventListener("click", function(ev) {
button.addEventListener("click", function (ev) {
ev.preventDefault()
/* Retrieve and send data */
@@ -146,13 +153,12 @@
/* Show feedback */
feedback.hidden = false
}
}
})
/* Send page view on location change */
if (typeof location$ !== "undefined")
location$.subscribe(function(url) {
ga("send", "pageview", url.pathname)
})
location$.subscribe(function(url) {
ga("send", "pageview", url.pathname)
})
})
/* Create script tag */