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: 5d1e297

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 (combobox demo): Detect valid entries when typed, but not selected from menu. Fixes #5605 - Autocomplete combobox demo does not accept valid values.
scottgonzalez (author)
Tue Jul 20 11:35:54 -0700 2010
commit  5d1e29764024128e9cc7
tree    c9e3cca38e0b4c7fc601
parent  ba091650ffdd2e359624
M demos/autocomplete/combobox.html 20 ••••
Txt demos/autocomplete/combobox.html
  • View file @ 5d1e297
... ...
@@ -29,7 +29,7 @@
29 29
             delay: 0,
30 30
             minLength: 0,
31 31
             source: function( request, response ) {
32  
-              var matcher = new RegExp( request.term, "i" );
  32
+              var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
33 33
               response( select.children( "option" ).map(function() {
34 34
                 var text = $( this ).text();
35 35
                 if ( this.value && ( !request.term || matcher.test(text) ) )
... ...
@@ -54,10 +54,20 @@
54 54
             },
55 55
             change: function( event, ui ) {
56 56
               if ( !ui.item ) {
57  
-                // remove invalid value, as it didn't match anything
58  
-                $( this ).val( "" );
59  
-                select.val( "" );
60  
-                return false;
  57
+                var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
  58
+                  valid = false;
  59
+                select.children( "option" ).each(function() {
  60
+                  if ( this.value.match( matcher ) ) {
  61
+                    this.selected = valid = true;
  62
+                    return false;
  63
+                  }
  64
+                });
  65
+                if ( !valid ) {
  66
+                  // remove invalid value, as it didn't match anything
  67
+                  $( this ).val( "" );
  68
+                  select.val( "" );
  69
+                  return false;
  70
+                }
61 71
               }
62 72
             }
63 73
           })

0 notes on commit 5d1e297

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
  • 中文