Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. unexpected result function autocomplete() Jquery

unexpected result function autocomplete() Jquery

Scheduled Pinned Locked Moved JavaScript
javascriptphpdata-structuresquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    serenimus
    wrote on last edited by
    #1

    Hallo! I have a textbox , (made with Zendform), and y load the results of an array in this textbox with the autocomplete(); function , this was performing as expected a few days ago, but today the result is disgusting..the results appear by the textbox this way: .Galicia .Asturias .[...] this function its asociated with a"keyup" event...please any idea of what could be wrong??, I executed in Chrome, and the compilator, shows no errors... :omg: thanks!! ;) so let´s go to the code $(document).ready(function(){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Islas Baleares" ]; <pre> $("#comu").keyup(function(){ $(this).autocomplete({ source:comunidades }); }); </pre> <pre> <label>Comunidad</label> <?php $fComu=$formNewClienteHotel->get("comunidad"); echo $this->formInput($fComu); ?> </pre> This is the class where the Form is declared:

    setAttributes(array(
    'action'=>'',
    'method'=>'post'
    ));

    	$this->add(array(
    		'name'=>'comunidad',
    		'attributes'=>array(
    		'type'=>'text',
    		'required'=>'required',
    		'id'=>'comu',
    		
    		)
    	));
    
    Richard DeemingR 1 Reply Last reply
    0
    • S serenimus

      Hallo! I have a textbox , (made with Zendform), and y load the results of an array in this textbox with the autocomplete(); function , this was performing as expected a few days ago, but today the result is disgusting..the results appear by the textbox this way: .Galicia .Asturias .[...] this function its asociated with a"keyup" event...please any idea of what could be wrong??, I executed in Chrome, and the compilator, shows no errors... :omg: thanks!! ;) so let´s go to the code $(document).ready(function(){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Islas Baleares" ]; <pre> $("#comu").keyup(function(){ $(this).autocomplete({ source:comunidades }); }); </pre> <pre> <label>Comunidad</label> <?php $fComu=$formNewClienteHotel->get("comunidad"); echo $this->formInput($fComu); ?> </pre> This is the class where the Form is declared:

      setAttributes(array(
      'action'=>'',
      'method'=>'post'
      ));

      	$this->add(array(
      		'name'=>'comunidad',
      		'attributes'=>array(
      		'type'=>'text',
      		'required'=>'required',
      		'id'=>'comu',
      		
      		)
      	));
      
      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Calling autocomplete on every key press will most likely cause problems. You would normally only call the autocomplete function once:

      $(function(){
      var comunidades = [
      "Galicia",
      "Asturias",
      "Cantabria",
      "Islas Baleares"
      ];

      $("#comu").autocomplete({
          source: comunidades
      });
      

      });

      If that doesn't work, then you'll need to tell us which autocomplete library you're using. NB: $(document).ready(...) is deprecated:

      .ready() | jQuery API Documentation[^]:

      jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:

      • $( handler )
      • $( document ).ready( handler )
      • $( "document" ).ready( handler )
      • $( "img" ).ready( handler )
      • $().ready( handler )

      As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      S 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Calling autocomplete on every key press will most likely cause problems. You would normally only call the autocomplete function once:

        $(function(){
        var comunidades = [
        "Galicia",
        "Asturias",
        "Cantabria",
        "Islas Baleares"
        ];

        $("#comu").autocomplete({
            source: comunidades
        });
        

        });

        If that doesn't work, then you'll need to tell us which autocomplete library you're using. NB: $(document).ready(...) is deprecated:

        .ready() | jQuery API Documentation[^]:

        jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:

        • $( handler )
        • $( document ).ready( handler )
        • $( "document" ).ready( handler )
        • $( "img" ).ready( handler )
        • $().ready( handler )

        As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        S Offline
        S Offline
        serenimus
        wrote on last edited by
        #3

        Hallo!! thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work.. :sigh: $(window).on("load",function(e){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Euskadi"] $("#comu").autocomplete({ source:comunidades }); }); "If that doesn't work, then you'll need to tell us which autocomplete library you're using" ?> Thank u!!! :)</x-turndown>

        S Richard DeemingR 2 Replies Last reply
        0
        • S serenimus

          Hallo!! thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work.. :sigh: $(window).on("load",function(e){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Euskadi"] $("#comu").autocomplete({ source:comunidades }); }); "If that doesn't work, then you'll need to tell us which autocomplete library you're using" ?> Thank u!!! :)</x-turndown>

          S Offline
          S Offline
          serenimus
          wrote on last edited by
          #4

          Uppss!! I forgot to add tue links to the Jquery Library...

          ?>

          1 Reply Last reply
          0
          • S serenimus

            Hallo!! thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work.. :sigh: $(window).on("load",function(e){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Euskadi"] $("#comu").autocomplete({ source:comunidades }); }); "If that doesn't work, then you'll need to tell us which autocomplete library you're using" ?> Thank u!!! :)</x-turndown>

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            $(function(){
            var comunidades = [
            "Galicia",
            "Asturias",
            "Cantabria",
            "Euskadi"
            ];

            $("#comu").autocomplete({
                source: comunidades
            });
            

            });

            Assuming you have an <input> with id="comu" somewhere in your document, and you've linked to the jQuery UI CSS[^] as well as the scripts, that should work. It's virtually identical to the first example on the jQuery UI site[^].


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            S 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              $(function(){
              var comunidades = [
              "Galicia",
              "Asturias",
              "Cantabria",
              "Euskadi"
              ];

              $("#comu").autocomplete({
                  source: comunidades
              });
              

              });

              Assuming you have an <input> with id="comu" somewhere in your document, and you've linked to the jQuery UI CSS[^] as well as the scripts, that should work. It's virtually identical to the first example on the jQuery UI site[^].


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              S Offline
              S Offline
              serenimus
              wrote on last edited by
              #6

              Hi!! thanks a lot for the answer... I had to go use a safe copy of the Projekt..becouse I finally didn`t find a solution :confused: Greetings!!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups