Hi Jose,

Since it looks like your hitting your own custom servlet, you might want to
look at using something already built.

I would take a look at:
http://jqueryui.com/autocomplete/#remote

Peter Dietz


On Tue, May 14, 2013 at 4:14 PM, Jose Blanco <[email protected]> wrote:

> I would like to use autocomplete to help users when entering authors in
> the submission form.  We have presently 100K different authors so the list
> is quite big.  I have tried a couple of things:
>
> (1)  Using the jquery version that comes with DSpace I did this, which
> basically tries to autocomplete once the author enters "lastnam,":
>
>  
> $('#aspect_submission_StepTransformer_field_dc_contributor_author1').keyup(function()
> {
>        var input =
> $("#aspect_submission_StepTransformer_field_dc_contributor_author").val();
>        input = $.trim(input);
>
>        var size = input.indexOf(",") + 1;
>        var how_long = input.length;
>        var all = size + " " + how_long;
>        if(size == how_long) {
>          //var newstr = input.replace(/(.*\,).*/, "$1");
>      var newstr = input;
>      $("#suggest").html("");
>          $.ajax({
>        url: "http://blancoj.dev.deepblue.lib.umich.edu/cgi/authors";,
>        data : "input="+newstr,
>            success: function(msg) { $("#suggest").html(msg);  }
>        });
>        }
>     });
>
> -What I observed was that typing at a normal speed, I could type so fast
> that the options never got displayed, and the same thing happened when I
> update to a more current version of jquery and tried this code:
>
>
> $('#aspect_submission_StepTransformer_field_dc_contributor_author').keyup(function()
> {
>        var input =
> $("#aspect_submission_StepTransformer_field_dc_contributor_author").val();
>
>        var size = input.indexOf(",") + 2;
>        var how_long = input.length;
>        var all = size + " " + how_long;
>
>        if((size == how_long) && ( size > 1 )) {
>      var newstr = input;
>      var result;
>
>      var jqxhr =  $.ajax({
>        type: "get",
>            url: "http://blancoj.dev.deepblue.lib.umich.edu/cgi/authors2";,
>            data :  "input="+newstr,
>            dataType: "xml",
>            async: false,
>            success: function(data) { return data;  }
>        }).responseText;
>
>      var xml_string = jqxhr;
>
>      // Parse the XML string into a XMLDocument
>      var doc = window.DOMParser
>        ? new DOMParser().parseFromString(xml_string, 'text/xml')    //
> Standard
>        : new ActiveXObject('Microsoft.XMLDOM').loadXML(xml_string); // IE
>
>      // Find the answer nodes
>      var answers_nodes = doc.getElementsByTagName('data');
>      var answers = [];
>
>      // Loop through them and save their text content into an array
>      for (var i = 0; i < answers_nodes.length; i++) {
>        answers.push(answers_nodes[i].firstChild.data)
>      }
>        answers.push("")
>
>      $( "#aspect_submission_StepTransformer_field_dc_contributor_author"
> ).autocomplete({
>        source: answers
>      });
>
>        }
>     });
>
> Any insight into this?
>
> Thank you!
> Jose
>
>
> ------------------------------------------------------------------------------
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
> _______________________________________________
> DSpace-tech mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dspace-tech
> List Etiquette:
> https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette
>
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette

Reply via email to