diff --git a/js/id/ui/raw_tag_editor.js b/js/id/ui/raw_tag_editor.js index e4b760e8f..8b601303a 100644 --- a/js/id/ui/raw_tag_editor.js +++ b/js/id/ui/raw_tag_editor.js @@ -114,6 +114,7 @@ iD.ui.RawTagEditor = function(context) { .on('click', removeTag); $items.exit() + .each(unbind) .remove(); function pushMore() { @@ -165,6 +166,16 @@ iD.ui.RawTagEditor = function(context) { })); } + function unbind() { + var row = d3.select(this); + + row.selectAll('input.key') + .call(d3.combobox.off); + + row.selectAll('input.value') + .call(d3.combobox.off); + } + function keyChange(d) { var kOld = d.key, kNew = this.value.trim(), diff --git a/js/lib/d3.combobox.js b/js/lib/d3.combobox.js index bd8482f80..083b1a970 100644 --- a/js/lib/d3.combobox.js +++ b/js/lib/d3.combobox.js @@ -271,3 +271,23 @@ d3.combobox = function() { return d3.rebind(combobox, event, 'on'); }; + +d3.combobox.off = function(input) { + data = null; + fetcher = null; + + input + .on('focus.typeahead', null) + .on('blur.typeahead', null) + .on('keydown.typeahead', null) + .on('keyup.typeahead', null) + .on('input.typeahead', null) + .each(function() { + d3.select(this.parentNode).selectAll('.combobox-caret') + .filter(function(d) { return d === input.node(); }) + .on('mousedown', null); + }); + + d3.select(document.body) + .on('scroll.combobox', null); +};