From cc57821b0ab3c718dc1b9357bf91ec37c63c2291 Mon Sep 17 00:00:00 2001 From: Sinan AKYAZICI Date: Sun, 16 Sep 2012 07:42:00 +0300 Subject: [PATCH] Update src/jquery.autocomplete.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Need an element to store the data. So we define the id of we want to store the element.  If be change in autocomplete, the element id will be cleaned. If be choice in autocomplete, the element id will be set. --- src/jquery.autocomplete.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index d9e2ab0..5fd2181 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -45,7 +45,8 @@ params: {}, fnFormatResult: fnFormatResult, delimiter: null, - zIndex: 9999 + zIndex: 9999, + valueElementId='' }; this.initialize(); this.setOptions(options); @@ -212,6 +213,7 @@ }, onValueChange: function () { + $("#" + this.options.valueElementId).val(''); clearInterval(this.onChangeInterval); this.currentValue = this.el.val(); var q = this.getQuery(this.currentValue); @@ -417,6 +419,7 @@ s = me.suggestions[i]; d = me.data[i]; me.el.val(me.getValue(s)); + $("#" + me.options.valueElementId).val(me.getValue(d)); if ($.isFunction(fn)) { fn(s, d, me.el); } },