diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-01-18 13:25:10 -0600 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-01-18 13:25:10 -0600 |
commit | 7c29f03e23c0a87b1dc9dacda173f40de17378eb (patch) | |
tree | 9d05e527985dd9e2eecb66c9d0de1a5d1927bd27 | |
parent | 1cc6d206b5d4cf09bb502a254703f3a2de2dbeb7 (diff) | |
download | gitlab-ce-7c29f03e23c0a87b1dc9dacda173f40de17378eb.tar.gz |
ensure click event is bound only once26825-diff-unfolding-within-merge-request-changes-tab-triggers-two-ajax-requests
-rw-r--r-- | app/assets/javascripts/diff.js.es6 | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/assets/javascripts/diff.js.es6 b/app/assets/javascripts/diff.js.es6 index 5e1a4c948aa..328d383a060 100644 --- a/app/assets/javascripts/diff.js.es6 +++ b/app/assets/javascripts/diff.js.es6 @@ -2,6 +2,7 @@ (() => { const UNFOLD_COUNT = 20; + let isBound = false; class Diff { constructor() { @@ -15,10 +16,12 @@ $('.content-wrapper .container-fluid').removeClass('container-limited'); } - $(document) - .off('click', '.js-unfold, .diff-line-num a') - .on('click', '.js-unfold', this.handleClickUnfold.bind(this)) - .on('click', '.diff-line-num a', this.handleClickLineNum.bind(this)); + if (!isBound) { + $(document) + .on('click', '.js-unfold', this.handleClickUnfold.bind(this)) + .on('click', '.diff-line-num a', this.handleClickLineNum.bind(this)); + isBound = true; + } this.openAnchoredDiff(); } |