From c3c849927d42c4ba5431b3970dab63fdb89b77f5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Fri, 21 Jun 2013 22:29:30 +0300 Subject: [PATCH] Unbind note events to prevent firing twice with turbolinks --- app/assets/javascripts/notes.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index f5005ec2c94..e0715f45417 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -1,5 +1,5 @@ var NoteList = { - + id: null, notes_path: null, target_params: null, target_id: 0, @@ -16,6 +16,16 @@ var NoteList = { // get initial set of notes NoteList.getContent(); + // Unbind events to prevent firing twice + $(document).off("click", ".js-add-diff-note-button"); + $(document).off("click", ".js-discussion-reply-button"); + $(document).off("click", ".js-note-preview-button"); + $(document).off("click", ".js-note-attachment-input"); + $(document).off("click", ".js-close-discussion-note-form"); + $(document).off("click", ".js-note-delete"); + $(document).off("ajax:complete", ".js-main-target-form"); + + // add a new diff note $(document).on("click", ".js-add-diff-note-button", -- 2.30.9