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:
@@ -9,13 +9,13 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
submitOnChange: function() {
|
submitOnChange: function() {
|
||||||
$(".js-submit-on-change").off("change").on("change", function() {
|
$("body").on("change", ".js-submit-on-change", function() {
|
||||||
$(this).closest("form").submit();
|
$(this).closest("form").submit();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
toggleLink: function() {
|
toggleLink: function() {
|
||||||
$(".js-toggle-link").off("click").on("click", function() {
|
$("body").on("click", ".js-toggle-link", function() {
|
||||||
var toggle_txt;
|
var toggle_txt;
|
||||||
$($(this).data("toggle-selector")).toggle("down");
|
$($(this).data("toggle-selector")).toggle("down");
|
||||||
if ($(this).data("toggle-text") !== undefined) {
|
if ($(this).data("toggle-text") !== undefined) {
|
||||||
|
|||||||
@@ -69,14 +69,14 @@
|
|||||||
$("#comments-box").html("");
|
$("#comments-box").html("");
|
||||||
App.LegislationAllegations.show_comments();
|
App.LegislationAllegations.show_comments();
|
||||||
$("#comments-box").show();
|
$("#comments-box").show();
|
||||||
$.event.trigger({
|
$("body").trigger({
|
||||||
type: "renderLegislationAnnotation",
|
type: "renderLegislationAnnotation",
|
||||||
annotation_id: target.data("annotation-id"),
|
annotation_id: target.data("annotation-id"),
|
||||||
annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url"),
|
annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url"),
|
||||||
offset: target.offset().top
|
offset: target.offset().top
|
||||||
});
|
});
|
||||||
parents_ids.each(function(i, pid) {
|
parents_ids.each(function(i, pid) {
|
||||||
$.event.trigger({
|
$("body").trigger({
|
||||||
type: "renderLegislationAnnotation",
|
type: "renderLegislationAnnotation",
|
||||||
annotation_id: pid,
|
annotation_id: pid,
|
||||||
annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url")
|
annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url")
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
$("html,body").animate({
|
$("html,body").animate({
|
||||||
scrollTop: el.offset().top
|
scrollTop: el.offset().top
|
||||||
});
|
});
|
||||||
$.event.trigger({
|
$("body").trigger({
|
||||||
type: "renderLegislationAnnotation",
|
type: "renderLegislationAnnotation",
|
||||||
annotation_id: ann_id,
|
annotation_id: ann_id,
|
||||||
annotation_url: el.closest(".legislation-annotatable").data("legislation-annotatable-base-url"),
|
annotation_url: el.closest(".legislation-annotatable").data("legislation-annotatable-base-url"),
|
||||||
@@ -188,9 +188,9 @@
|
|||||||
},
|
},
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var current_user_id;
|
var current_user_id;
|
||||||
$(document).off("renderLegislationAnnotation").on("renderLegislationAnnotation", App.LegislationAnnotatable.renderAnnotationComments);
|
$("body").on("renderLegislationAnnotation", App.LegislationAnnotatable.renderAnnotationComments);
|
||||||
$(document).off("click", "[data-annotation-id]").on("click", "[data-annotation-id]", App.LegislationAnnotatable.onClick);
|
$("body").on("click", "[data-annotation-id]", App.LegislationAnnotatable.onClick);
|
||||||
$(document).off("click", "[data-cancel-annotation]").on("click", "[data-cancel-annotation]", function(e) {
|
$("body").on("click", "[data-cancel-annotation]", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#comments-box").html("");
|
$("#comments-box").html("");
|
||||||
$("#comments-box").hide();
|
$("#comments-box").hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user