Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method

Regarding the answer to Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'destroy', 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?

sprintf(<<<EOF
<script type="text/javascript">
  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]); });
  });
</script>
EOF
      ,
      $this->generateId('autocomplete_'.$name),
      $this->getOption('url'),
      $this->getOption('config'),
      $this->generateId($name)
    );

Answers


Try that:

    return $this->renderTag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value)).
           parent::render('autocomplete_'.$name, $visibleValue, $attributes, $errors).
           sprintf(<<<EOF
<script type="text/javascript">
  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]); });
  });

  // manually trigger autocomplete
  jQuery("#%s").find('input').autocomplete();
</script>
EOF
      ,
      $this->generateId('autocomplete_'.$name),
      $this->getOption('url'),
      $this->getOption('config'),
      $this->generateId($name),
      $this->generateId('autocomplete_'.$name)
    );
  }

Need Your Help

How to make a carousel not shake while scrolling and pause on hover

javascript jquery html scroll carousel

The issue is every time AnimateCarousel() is called, the images jumps to the right a little in the slider before continuing. How can I prevent it?

Error with package "RgoogleMaps" HTTP status was '403 Forbidden'

r rgooglemaps

I am trying to make maps with RgoogleMaps. My code used to work this morning but now I get this error :