Prevent default event on JavaScript-only links

These links point to "#" and don't do anything without JavaScript
activated, and they were causing the browser to scroll to the top of the
page.
This commit is contained in:
Javi Martín
2019-09-13 17:44:12 +02:00
parent ae2b4b16c6
commit f8c9f09887
3 changed files with 15 additions and 5 deletions

View File

@@ -2,13 +2,17 @@
"use strict";
App.CheckAllNone = {
initialize: function() {
$("[data-check-all]").on("click", function() {
$("[data-check-all]").on("click", function(e) {
var target_name;
e.preventDefault();
e.stopPropagation();
target_name = $(this).data("check-all");
$("[name='" + target_name + "']").prop("checked", true);
});
$("[data-check-none]").on("click", function() {
$("[data-check-none]").on("click", function(e) {
var target_name;
e.preventDefault();
e.stopPropagation();
target_name = $(this).data("check-none");
$("[name='" + target_name + "']").prop("checked", false);
});