title: triggering JQuery 'autocomplete' in a secondary textarea
body: <p>We currently have two HTML textareas 'tinput'(primary) and 'toutput' (secondary) where we mimic the input in the primary to be reflected in the secondary as if someone is really typing in the secondary. The idea is to trigger an 'autocomplete' (over ajax) on the secondary.  We have this working but not optimally.</p>
  
  <p>We have attached a JQuery UI 'Autocomplete' (JQAC) to the secondary with a minLength:3 set.  You may know that, normally, after 3 characters have been entered, JQAC 'buffers' the char entries thereon after and doesn't make an ajax call for every char that has been entered.  Which is ideal.</p>
  
  <p>However, with our secondary mimicking we have subverted this behavior, unfortunately, where after the 3rd char entry a JQAC ajax call is being made for every char after-- which is not optimal.  We know why but don't know how to get around it.  We believe we've subverted this because we are calling </p>
  
  <pre><code>  $('#tinput').autocomplete('search',$('#tinput').val()) 
  </code></pre>
  
  <p>in the secondary's key handle, which by JQAC's documentation forces an ajax call.</p>
  
  <p>To summarize, we need the secondary, that has JQAC attached to it, to behave as if someone were really typing into it and the JQAC behaving normally.</p>
  
  <p>Here is JS for what we have as our char input mimic handling(we've changed variable names for this post so please ignore typos):</p>
  
  <pre><code>$("#tinput").on('input', function (e) {
      $("#toutput").val($("#tinput").text());
  
      var newEvent = jQuery.Event("keypress");
      newEvent.which = e.which; // # Some key code value
      $("#toutput").trigger(newEvent);
  });
  
  $("#toutput").keypress(function(e) {
  
     $("#toutput").autocomplete('search',$("#toutput").val());
  });
  
  $( "#tinput" ).autocomplete({
    appendTo: "#modalparent",
    source: function( request, response ) {
      $.ajax({
        url: "https://xxxxxx",
        type: "POST",
        dataType: "json",
        data: JSON.stringify({ "ourterm": request.term}),
        success: function( data ) {
          response( $.map( data.data.suggestions, function( item ) {
            return {
              label: item,
              value: item
            };
          }));
        }
      });
    },
    minLength: 3,
    select: function( event, ui ) {
      // console.log( ui.item ?
      //   "Selected: " + ui.item.label :
      //   "Nothing selected, input was " + this.value);
    },
    open: function() {
      $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
    },
    close: function() {
      $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
    }
  });
  </code></pre>
  
  <p>Any thoughts would be appreciated.  Thanks!</p>