[js] fix initial value for autocomplete stable
authorKatia Saurfelt <katia.saurfelt@logilab.fr>
Thu, 09 Dec 2010 16:37:08 +0100
branchstable
changeset 6739 08cfa7019b27
parent 6732 f63cef610b97
child 6740 e4974d5f7dca
[js] fix initial value for autocomplete
web/data/cubicweb.widgets.js
--- a/web/data/cubicweb.widgets.js	Mon Nov 29 18:34:39 2010 +0100
+++ b/web/data/cubicweb.widgets.js	Thu Dec 09 16:37:08 2010 +0100
@@ -91,6 +91,11 @@
                 };
                 var hiHandlers = methods.hiddenInputHandlers;
                 $(this).data('cwautocomplete', instanceData);
+                // in case of an existing value, the hidden input must be initialized even if
+                // the value is not changed
+                if (($(instanceData.userInput).attr('cubicweb:initialvalue') !== undefined) && !instanceData.hiddenInput){
+                    hiHandlers.initializeHiddenInput(instanceData);
+                }
                 $.ui.autocomplete.prototype._search = methods.search;
                 if (settings.multiple) {
                     $.ui.autocomplete.filter = methods.multiple.makeFilter(this);