summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-10-02 11:07:52 +0200
committerAleš Smodiš <aless@guru.si>2015-10-02 11:07:52 +0200
commitf72d4a175d44283e1d2d35bccff706093600c1c2 (patch)
tree4c04c875de4f9a2743a9f7a43cc7e7cb10ddc9a4
parentdd58eed64f6464bbc5156c703ef238a0b6a56b3a (diff)
Bugfix console: remove click and blur event handlers on destroy, so new instances work correctly.
-rw-r--r--js/codeq/console.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/js/codeq/console.js b/js/codeq/console.js
index 859b064..ebf09cc 100644
--- a/js/codeq/console.js
+++ b/js/codeq/console.js
@@ -159,6 +159,8 @@
return result;
};
+ var instanceCounter = 1; // for generating unique console instance numbers
+
codeq.makeConsole = function (jqElt, options) {
var lines = [],// console content, line descriptors of the form {'content': 'string', 'classNames': [], 'jqLine': jQuery object, 'row': number}
maxLines = (options && options.maxLines) || 10000, // how many lines to display at most
@@ -172,6 +174,7 @@
history = [], // the list of entered lines, it is only appended
currentHistory = [], // the list of entered lines, some possibly modified (it is copied from history on each new line editing)
currentHistoryIndex = -1,
+ instanceNumber = instanceCounter++, // unique instace number, to be used with stuff tied to this instance, e.g.: jqElt events, life-cycle debug output
renderSpan = function (lineDescriptor, startCol, length) {
var jqLine = lineDescriptor.jqLine,
@@ -751,6 +754,8 @@
delete handler[i];
}
}
+ jqElt.off('click.console' + instanceNumber);
+ jqElt.off('blur.console' + instanceNumber);
jqElt.empty();
jqElt = null;
options = null;
@@ -910,11 +915,11 @@
jqElt.empty();
jqElt.append(jqContent);
jqElt.append(jqInput);
- jqElt.on('click', function () {
+ jqElt.on('click.console' + instanceNumber, function () {
// set focus to the textarea so we pick up keypresses
jqInput.css('position', 'fixed').focus();
});
- jqElt.on('blur', function () {
+ jqElt.on('blur.console' + instanceNumber, function () {
jqInput.css('position', 'absolute');
});