Commits

Anonymous committed d816496

Adjusting hAutoComplete to work in modal dialog boxes. Right now it disapears when you click on it, but it shouldn't.

Comments (0)

Files changed (1)

TestWebsite/Scripts/hAutoComplete/hAutoComplete.js

     });
 
     $.fn.hAutoComplete = function(options) {
-        var padding, shadow, offset, minimumSearchLength, toolTipContainer, toolTipShadow, showallButton, defaults, that, repositionPopup, getFilterResultsFromServer;
+        var padding, shadow, offset, minimumSearchLength, toolTipContainer, toolTipShadow, showallButton, defaults, that, repositionPopup, getFilterResultsFromServer, hideToolTip, showToolTip;
 
 
         that = this; //self reference variable to be used inside functions
         toolTipContainer = $('<div class="ui-widget ui-widget-content ui-corner-all">');
         toolTipShadow = $('<div class="ui-widget-shadow ui-corner-all"></div>');
         showallButton = $('<button>Get All Items</button>');
-        showallButton.button({ icons: { primary: 'ui-icon-folder-open' }, text: false });
         this.attr('name', ('hAutoCompleteBox_' + this.attr('id'))); //We will set the ajax name so that we will know what ajaxID to wait for if we need to
 
         //Make sure that a URL was specified
             }, false);
         };
 
+        var hideToolTip = function(event) {
+            toolTipContainer.remove();
+            toolTipShadow.remove();
+        };
+        var showToolTip = function(element) {
+            element.after(toolTipShadow);
+            element.after(toolTipContainer);
+            toolTipContainer.show();
+            toolTipShadow.show();
+            showallButton.button({ icons: { primary: 'ui-icon-folder-open' }, text: false });
+        };
         $(document).click(function(event) {
-            toolTipContainer.hide();
-            toolTipShadow.hide();
+            hideToolTip(event);
         });
         $('body *').focus(function(event) {
-            toolTipContainer.hide();
-            toolTipShadow.hide();
+            hideToolTip(event);
             event.stopPropagation(); return false;
         });
         $(window).resize(function() {
         toolTipContainer.append($('<span style="display:inline">Start typing the description or the part number to filter, or click </span>'));
         toolTipContainer.append(showallButton);
         toolTipContainer.append($('<span style="display:inline"> if you want to see the whole list.</span>'));
-        toolTipContainer.hide();
-        toolTipShadow.hide();
 
-        $('body').append(toolTipShadow);
-        $('body').append(toolTipContainer);
+        //toolTipContainer.remove();
+        //toolTipShadow.remove();
+
 
         this.click(function(event) {
             event.stopPropagation();
             toolTipContainer.css({
                 top: (element.position().top - toolTipContainer.height() - (padding * 2) - offset),
                 left: element.position().left,
-                'z-index': 1000
+                'z-index': 5000
             });
 
             toolTipShadow.css({
 
         this.focus(function() {
             var element = $(this);
+            showToolTip(element);
+
             $.fn.hAutoComplete.prototype.lastfocusedInputbox = $(this);
-            toolTipContainer.show();
-            toolTipShadow.show();
             repositionPopup(element);
             toolTipContainer.data('associated', element);