github github
  • Home
  • Pricing and Signup
  • Training
  • Gist
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 921
    • 212
  • Source
  • Commits
  • Network (212)
  • Graphs
  • Tree: 612838a

click here to add a description

click here to add a homepage

  • Switch Branches (8)
    • bind
    • devpreview
    • formcontrols
    • master
    • menu
    • panel
    • tooltip
    • widget-super
  • Switch Tags (21)
    • 1.9m2
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 1.8.4
    • 1.8.3
    • 1.8.2
    • 1.8.1
    • 1.8
    • 1.7
    • 1.6rc6
    • 1.6rc5
    • 1.6rc3
    • 1.6rc2
    • 1.6
    • 1.5.2
    • 1.5.1
  • Comments
  • Contributors
Sending Request…

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Autocomplete: Added position option. Fixes #5153 - Autocomplete position option.
scottgonzalez (author)
Mon Jul 19 06:28:04 -0700 2010
commit  612838a1518c8cdc80b5
tree    77d609f44c6f0c329669
parent  5435c50765e89f5cfb1c
M tests/unit/autocomplete/autocomplete_defaults.js 7 ••••
M ui/jquery.ui.autocomplete.js 17 ••••
Txt tests/unit/autocomplete/autocomplete_defaults.js
  • View file @ 612838a
... ...
@@ -6,7 +6,12 @@ var autocomplete_defaults = {
6 6
   delay: 300,
7 7
   disabled: false,
8 8
   minLength: 1,
9  
-  source: undefined
  9
+  position: {
  10
+    my: "left top",
  11
+    at: "left bottom",
  12
+    collision: "none"
  13
+  },
  14
+  source: null
10 15
 };
11 16
 
12 17
 commonWidgetTests('autocomplete', { defaults: autocomplete_defaults });
Txt ui/jquery.ui.autocomplete.js
  • View file @ 612838a
... ...
@@ -16,8 +16,14 @@
16 16
 
17 17
 $.widget( "ui.autocomplete", {
18 18
   options: {
  19
+    delay: 300,
19 20
     minLength: 1,
20  
-    delay: 300
  21
+    position: {
  22
+      my: "left top",
  23
+      at: "left bottom",
  24
+      collision: "none"
  25
+    },
  26
+    source: null
21 27
   },
22 28
   _create: function() {
23 29
     var self = this,
... ...
@@ -269,12 +275,9 @@ $.widget( "ui.autocomplete", {
269 275
     // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
270 276
     this.menu.deactivate();
271 277
     this.menu.refresh();
272  
-    this.menu.element.show().position({
273  
-      my: "left top",
274  
-      at: "left bottom",
275  
-      of: this.element,
276  
-      collision: "none"
277  
-    });
  278
+    this.menu.element.show().position( $.extend({
  279
+      of: this.element
  280
+    }, this.options.position ));
278 281
 
279 282
     menuWidth = ul.width( "" ).outerWidth();
280 283
     textWidth = this.element.outerWidth();

3 notes on commit 612838a

jzaefferer added a note to 612838a repo collab

Tue Jul 20 00:36:06 -0700 2010

Shouldn't the arguments to $.extend be switched? Or do we want to allow the user to specify the of-property?

scottgonzalez added a note to 612838a repo collab

Tue Jul 20 04:52:49 -0700 2010

I wanted it to be as flexible as possible. If the user really wants to specify a different element to position against, they can, but they'd have to intentionally do it. This probably allows for some crazy kind of complex autocomplete UI that somebody will think of one day :-P

jzaefferer added a note to 612838a repo collab

Tue Jul 20 04:57:56 -0700 2010

Yeah, makes sense. We should apply the same logic elsewhere, eg. I'm pretty sure tooltip needs an update.

Please log in to comment.
Dedicated Server Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
  • Blog
  • Support
  • Training
  • Job Board
  • Shop
  • Contact
  • API
  • Status
  • © 2010 GitHub Inc. All rights reserved.
  • Terms of Service
  • Privacy
  • Security
  • English
  • Deutsch
  • Français
  • 日本語
  • Português (BR)
  • 中文
  • See all available languages

Your current locale selection: English. Choose another?

  • English
  • Afrikaans
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Српски
  • Svenska
  • 中文