Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:45:35+00:00 2026-05-28T01:45:35+00:00

I need a jquery autocomplete that only does one call to the server then

  • 0

I need a jquery autocomplete that only does one call to the server then stores locally and uses the returned array in subsequent calls in a jqgrid. it shoud also work outside the grid for othe autocmpletes;
i have a jquery function in my onload:

$('#text').myAutocomplete({url:'...'});

And another one in a jqgrid – the dataInit below is a callback that uses a textbox argument to be autocmpleted/modified in other ways
I am using a asp.net web service hence the msg.d in my ajax call

$('#table').jqGrid({
  ...,
  colModel:[...,
           name:'col1',...,dataInit:function(el){
                       $.myAutocomplete({url:'..',elem:el});
                       }
           ...],
  ...
});

then in my Autocomplete function:

(function($){
 var returnArray = [];
 $.fn.myAutocomplete = function(options){
   var element = options.elem || this;
   if(returnArray.length === 0){ //checking if the local array is populated or not
     $.ajax({ // all other ajax options for asp.net webservice to respond are also set here
     ...,
     url: options.url,
     success : function(msg){
                returnArray = msg.d;
               }
     });
    }
  return element.autocomplete({source:returnArray}); 
  }
})(jQuery);

problem is the autocomplete on the ‘text’ is not working – I will test the jqgrid autocompleter tommorrow at work

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:45:36+00:00Added an answer on May 28, 2026 at 1:45 am

    /*Decided to change the approach;
    wrote the following code
    calling my autocomplte for a textbox
    */

    $('#textbox').txtAc({url:txtUrl});
    

    //Calling the autocomplete from a call back in a jqgrid

    dataInit:function(elem){
    var gridArray;
    var gridAc = $.getMyGridAc();
    gridArray = gridAc.getStoredArray();
    elem.autocomplete({source:gridArray});
    };
    

    //Among the plugins/ functions are:

    (function($){
      $.myAc = function(options){
       var storedArray = [];
    
       $.fillStoredArray = function(){
         $.ajax({url:options.url,
                 ...,
                 success:function(msg){
                         storedArray = msg.d;
                         if(options.el){
                             options.el.autocomplete({source:storedArray}); //1st time called, call jquery ui autocomplete from the ajax call if the element was specified (textbox); grid cant specify element in advance
                            }
                         }
         });
       }
       return {
         getStoredArray :function(){
                           if (storedArray.length === 0){
                           $.fillStoredArray();
                         }
          return storedArray;
               }
      }
     }
    })(jQuery);
    

    /*Now I can start reusing my plugin – below for a jqgrid call back then for a regular text box
    jqgrid auto complete:

    for the jqgrid, 1st create and return a closure instance from $.myAc :

    */

    (function($){
       $.prepareGridForAc = function(){
          var myGridAc = $.myAc({url:gridUrl});
          return function getMyGridAc (){
            return myGridAc;
          } 
       }
    })(jQuery);
    

    //when user loads grid for 1st time (or activates tab that grid is on)- call the prepareGridForAc

    //
    $.prepareGridforAc();
    //
    

    //textbox auto complete:

    (function($){
      $.fn.txtAc = function(options){
        var myTxtAc ;
        var acArray;
        $.extend(options,el:this);
        myTxtAc = $.myAc(options);
        acArray = myTxtAc.getStoredArray();
        return this.autocomplete({source:acArray});
      }
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a jquery script section that checks to see if the first digit
using jquery I need to retrieve an array from table cells, format the data
I need to limit the jquery ui date picker to only have future Tuesdays
I got the jQuery autocomplete form mostly working how I need it to work
Lots of style-related jquery autocomplete questions (yow), but none that want to "match the
Im currently using the JQuery UI extension for its search autocomplete. However, I need
do you know a jQuery Autocomplete Plugin that has the following features. I have
I'm attempting to use JQuery autocomplete and need to get the id of the
I'm happily using this autocompleter: http://code.google.com/p/jquery-autocomplete/ . I need to change the width of
I call the autocomplete jquery with the result of a GET request. The autocomplete

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.