Skip to content

Commit c3907a9

Browse files
author
Paige Bolduc
committed
Fix extra event listener bug
Before, every time the hidePreview function was called, additional event listeners were being appended to the DOM. This sorts out that functionality so that they are only appended when the editor is initialized.
1 parent 5ecd7a2 commit c3907a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

js/bootstrap-markdown.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@
167167
this.$textarea.css('resize', this.$options.resize);
168168
}
169169

170+
// Re-attach markdown data
171+
this.$textarea.data('markdown', this);
172+
},
173+
__setEventListeners: function() {
170174
this.$textarea.on({
171175
'focus': $.proxy(this.focus, this),
172176
'keyup': $.proxy(this.keyup, this),
@@ -181,9 +185,6 @@
181185
if (this.eventSupported('keypress')) {
182186
this.$textarea.on('keypress', $.proxy(this.keypress, this));
183187
}
184-
185-
// Re-attach markdown data
186-
this.$textarea.data('markdown', this);
187188
},
188189
__handle: function(e) {
189190
var target = $(e.currentTarget),
@@ -418,6 +419,7 @@
418419
this.$oldContent = this.getContent();
419420

420421
this.__setListener();
422+
this.__setEventListeners();
421423

422424
// Set editor attributes, data short-hand API and listener
423425
this.$editor.attr('id', (new Date()).getTime());

0 commit comments

Comments
 (0)