r3372 committed - autocomplete: add and remove a ui-autocomplete-loading class when gett...

r3372 committed - autocomplete: add and remove a ui-autocomplete-loading class when gett...


Revision: 3372
Author: joern.zaefferer
Date: Sat Oct 17 05:09:52 2009
Log: autocomplete: add and remove a ui-autocomplete-loading class when
getting data
http://code.google.com/p/jquery-ui/source/detail?r=3372
Modified:
/branches/dev/tests/visual/autocomplete/remote-jsonp.html
/branches/dev/ui/jquery.ui.autocomplete.js
=======================================
--- /branches/dev/tests/visual/autocomplete/remote-jsonp.html    Sat Oct 17
04:45:26 2009
+++ /branches/dev/tests/visual/autocomplete/remote-jsonp.html    Sat Oct 17
05:09:52 2009
@@ -47,21 +47,14 @@
            },
            minLength: 2,
            change: function(event, ui) {
-                $(this).removeClass("loading");
                log(ui.item ? ("Selected: " + ui.item.label) : "Nothing selected,
input was " + this.value);
-            },
-            search: function() {
-                $(this).addClass("loading");
-            },
-            open: function() {
-                $(this).removeClass("loading");
            }
        }).focus();
    });
    </script>
    <style>
        body { font-size:62.5%; }
-        .loading { background: url(indicator.gif) no-repeat right; }
+        .ui-autocomplete-loading { background: url(indicator.gif) no-repeat
right; }
    </style>
</head>
<body>
=======================================
--- /branches/dev/ui/jquery.ui.autocomplete.js    Sat Oct 17 05:04:47 2009
+++ /branches/dev/ui/jquery.ui.autocomplete.js    Sat Oct 17 05:09:52 2009
@@ -91,6 +91,7 @@
        if (value.length >= this.options.minLength) {
            if (this._trigger("search") === false)
                return;
+            self.element.addClass("ui-autocomplete-loading");
            function response(content) {
                if (content.length) {
                    self._trigger("open");
@@ -98,6 +99,7 @@
                } else {
                    self.close();
                }
+                self.element.removeClass("ui-autocomplete-loading");
            }
            // source can call response or return content directly
            var result = this.source({ term: value }, response);