Do not remove click event definition before defining it

Use delegated handlers instead so there is not risk to run method
multiple times.
This commit is contained in:
Senén Rodero Rodríguez
2020-07-27 11:29:37 +02:00
parent 009c33d4e5
commit 45a80af793
2 changed files with 8 additions and 8 deletions

View File

@@ -9,13 +9,13 @@
});
},
submitOnChange: function() {
$(".js-submit-on-change").off("change").on("change", function() {
$("body").on("change", ".js-submit-on-change", function() {
$(this).closest("form").submit();
return false;
});
},
toggleLink: function() {
$(".js-toggle-link").off("click").on("click", function() {
$("body").on("click", ".js-toggle-link", function() {
var toggle_txt;
$($(this).data("toggle-selector")).toggle("down");
if ($(this).data("toggle-text") !== undefined) {