Commits

noobtech  committed ccb3c93

Fixed some issues with multiple dropdown controls on one page.

  • Participants
  • Parent commits 967f7c6
  • Branches custom_tooltip

Comments (0)

Files changed (2)

File TestWebsite/Scripts/hAutoComplete/hAutoComplete.js

     };
 
 
-    $.fn.hAutoComplete = function(options) {
+    $.fn.hAutoComplete = function(options, setValue) {
+        if (options === 'set') {
+            $.fn.hAutoComplete.prototype.val.call(this, { term: setValue });
+            return;
+        }
+
         var padding, minimumSearchLength, toolTipContainer, showallButton, defaults, that, repositionPopup, getFilterResultsFromServer, hideToolTip, showToolTip, showAllButtonId, msg, otherElementFocus;
 
 
         a public function and lets user to programatically pre-fill
         our autocomplete text input box.
         */
-        $.fn.hAutoComplete.val = function(inputOptions) {
-            var msg, options;
-
+        $.fn.hAutoComplete.prototype.val = function(inputOptions) {
+            var msg, options, thisElement;
+            thisElement = $(this);
             options = {
                 term: ''
             };
 
             getFilterResultsFromServer(options, function(result) {
                 if (result.length === 1) {
-                    that.data("uiItem", result[0].id);
-                    that.val(result[0].id);
+                    thisElement.data("uiItem", result[0].id);
+                    thisElement.val(result[0].id);
                 } else {
-                    that.val(that.data("uiItem"));
+                    thisElement.val(thisElement.data("uiItem"));
                 }
             }, false);
         };
                 return;
             }
             toolTipContainer.remove();
-            //that.hAutoComplete.val({ term: that.val() });
         };
 
 
         if (this.data('initalized')) {
             this.autocomplete("destroy");
         }
-        
+
         this.autocomplete(defaults);
         this.data('initalized', true);
 
         this.unbind("blur.BlurInputTextBox");
         this.bind("blur.BlurInputTextBox", function(event) {
             var theInputBox = $(this);
-
             setTimeout(function() {
                 if (!that.data('showAllClicked')) {
                     if (theInputBox.val().length <= 0) {
                         theInputBox.val(theInputBox.data("uiItem"));
                     }
-                    theInputBox.hAutoComplete.val({ term: theInputBox.val() });
+                    if (theInputBox.val().length <= 0) {
+                        return;
+                    }
+                    $.fn.hAutoComplete.prototype.val.call(theInputBox, { term: theInputBox.val() });
                 } else {
                     that.data('showAllClicked', false);
                 }

File TestWebsite/Views/hAutoComplete/Index.aspx

 	        
 	        $(document).ready(function() {
 	            //Remote example is here: http://jqueryui.com/demos/autocomplete/remote.html
-	        $("#selector").hAutoComplete({ source: '<%=Url.Action("Search","hAutoComplete") %>' });
-	        $("#selector").hAutoComplete({ source: '<%=Url.Action("Search2","hAutoComplete") %>' });
+	        //$("#selector").hAutoComplete({ source: '<%=Url.Action("Search","hAutoComplete") %>' });
+	        //$("#selector").hAutoComplete({ source: '<%=Url.Action("Search2","hAutoComplete") %>' });
 	        $("#selector").hAutoComplete({ source: '<%=Url.Action("Search","hAutoComplete") %>' });
 	        $("#testing2").hAutoComplete({ source: '<%=Url.Action("Search","hAutoComplete") %>' });
-	        $('#testing2').hAutoComplete.val('arnold');
+	        $('#testing2').hAutoComplete('set','arnold');
 	        });