From: Michael J. Rubinsky Date: Sun, 23 May 2010 20:30:42 +0000 (-0400) Subject: Need to unregister the blur handler when showing the KNL X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6127fb9abfd5901832a1730d8ba4f7f4e8cff7d1;p=horde.git Need to unregister the blur handler when showing the KNL Showing the KNL causing the trigger to blur, triggering the code that adds the current value to the prettyautocompleter's list. --- diff --git a/horde/js/prettyautocomplete.js b/horde/js/prettyautocomplete.js index c1db325a3..069c4bdc4 100644 --- a/horde/js/prettyautocomplete.js +++ b/horde/js/prettyautocomplete.js @@ -47,9 +47,11 @@ var PrettyAutocompleter = Class.create({ // Build the DOM structure this.buildStructure(); + // Remember the bound method to unregister later. + this._boundProcessValue = this._processValue.bind(this); var trigger = $(this.p.trigger); trigger.observe('keydown', this._onKeyDown.bindAsEventListener(this)); - trigger.observe('blur', this._processValue.bind(this)); + trigger.observe('blur', this._boundProcessValue); // Make sure the p.items element is hidden if (!this.p.debug) { @@ -69,6 +71,9 @@ var PrettyAutocompleter = Class.create({ // Create the underlaying Autocompleter this.p.uri += '/input=' + this.p.trigger; + this.p.onShow = this._knvShow.bind(this); + this.p.onHide = this._knvHide.bind(this); + // Make sure the knl is contained in the overlay this.p.domParent = this.p.box; new Ajax.Autocompleter(this.p.trigger, this.p.uri, this.p); @@ -258,6 +263,15 @@ var PrettyAutocompleter = Class.create({ c = c.without(item.displayValue); }); return c; - } + }, + + _knvShow: function(l) + { + $(this.p.trigger).stopObserving('blur', this._boundProcessValue); + }, + _knvHide: function(l) + { + $(this.p.trigger).observe('blur', this._boundProcessValue); + } });