Results 1 to 3 of 3

Thread: Autocomplete Result Not Being Selected

  1. #1
    Join Date
    Apr 2012
    Posts
    85
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Autocomplete Result Not Being Selected

    Hello, I am almost done but I am facing an issue like when auto suggest give result I am not able to select it. Error comes in console that is of jquery only.
    Please type A or a inside top textbox

    http://xhtmljunkies.net/custom_phpld/

    Can you please help?

    Thanks
    Kaushal

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,374
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    You left out an important part of the custom _renderMenu function, or perhaps are using one that goes with an older version of the UI. Replace:

    Code:
            $.ui.autocomplete.prototype._renderMenu = function( ul, items ) {
                var self = this;
                $.each( items, function( index, item ) {
                if (index < 10) // here we define how many results to show
                    {self._renderItem( ul, item );}
                });
            }
    with

    Code:
            $.ui.autocomplete.prototype._renderMenu = function( ul, items ) {
                var that = this;
                $.each( items, function( index, item ) {
                if (index < 10) // here we define how many results to show
                    {that._renderItemData( ul, item );}
                });
            }
    The use of that instead of self as a variable name is probably minor but 'self' could confuse some browsers, it's synonymous with window and this in the global scope and because of that may even be reserved in some browsers. The important change is _renderItemData. Without that you get the error.

    And doing it like so:

    Code:
            $.ui.autocomplete.prototype._renderMenu = function( ul, items ) {
                var that = this;
                $.each( items, function( index, item ) {
                   if (index > 9) {return false;} // here we define how many results to show
                   that._renderItemData( ul, item );
                });
            }
    would be more efficient because it stops looping as soon as 10 matches are found.
    Last edited by jscheuer1; 12-22-2012 at 02:21 PM. Reason: detail
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2012
    Posts
    85
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi jscheuer1, Sorry for the late reply. I just came after many days. This is awesome. Thank you very much for this my friend

    You are awesome. I am having over 1500000 records so whenever I search like just pressing "A", my browser always get hanged so tha's why I thought it should be like limit 10 even if there exists 10 to 15 lakh records.

    Because of you only it is working now. Thanks Jscheuer1 I really appreciate your knowledge.

    Thanks again.
    Kaushal

Similar Threads

  1. Replies: 3
    Last Post: 12-18-2012, 06:56 AM
  2. Autosuggest/Autocomplete from database
    By newphpcoder in forum Other
    Replies: 4
    Last Post: 10-28-2011, 03:03 AM
  3. Resolved Joining result of multiple selects to get final result?
    By gwmbox in forum JavaScript
    Replies: 2
    Last Post: 01-04-2011, 01:18 PM
  4. [DHTML] AutoComplete with AJAX
    By BYK in forum Submit a DHTML or CSS code
    Replies: 8
    Last Post: 09-18-2008, 03:02 PM
  5. Manipulating the browser's AutoComplete?
    By Tohaki in forum JavaScript
    Replies: 2
    Last Post: 09-16-2008, 07:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •