Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method
<p>Regarding the answer to <a href="https://stackoverflow.com/questions/21549126/error-cannot-call-methods-on-autocomplete-prior-to-initialization-attempted-to">Error: cannot call methods on autocomplete prior to initialization; attempted to call method &#39;destroy&#39;</a>, apparently I need to ask as a new question! I am trying to use the Symfony sfWidgetFormJQueryAutocompleter plugin which uses the Jquery autocomplete library, the PHP render function for the JS is as follows.  Where would I add the $(this.target).find('input').autocomplete() line mentioned in the above post in the below code?</p>

<pre><code>sprintf(&lt;&lt;&lt;EOF
&lt;script type="text/javascript"&gt;
  jQuery(document).ready(function() {
    jQuery("#%s")
    .autocomplete('%s', jQuery.extend({}, {
      dataType: 'json',
      parse:    function(data) {
        var parsed = [];
        for (key in data) {
          parsed[parsed.length] = { data: [ data[key], key ], value:     data[key], result: data[key] };
        }
        return parsed;
      }
    }, %s))
    .result(function(event, data) { jQuery("#%s").val(data[1]); });
  });
&lt;/script&gt;
EOF
      ,
      $this-&gt;generateId('autocomplete_'.$name),
      $this-&gt;getOption('url'),
      $this-&gt;getOption('config'),
      $this-&gt;generateId($name)
    );
</code></pre>