Files
nairobi/app/assets/javascripts/turbolinks_anchors.js
Javi Martín ae2b4b16c6 Prevent AJAX requests to anchor links
Turbolinks 5 doesn't follow the browser's standard behaviour of ignoring
links pointing to "#", so we're preventing the turbolinks events in this
situation:
2020-08-05 14:10:22 +02:00

16 lines
459 B
JavaScript

(function() {
"use strict";
// Code by Dom Christie:
// https://github.com/turbolinks/turbolinks/issues/75#issuecomment-443256173
document.addEventListener("turbolinks:click", function(event) {
if (event.target.getAttribute("href").charAt(0) === "#") {
Turbolinks.controller.pushHistoryWithLocationAndRestorationIdentifier(
event.data.url,
Turbolinks.uuid()
);
event.preventDefault();
}
});
}).call(this);