I get the following error when launching a modal window in multivariate contrib module if I am using
Apache Solr setting "Autocomplete widget to use: Custom autocomplete widget".

TypeError: $(...).autocomplete is not a function
$(".apachesolr-autocomplete.unprocessed", context).autocomplete(Drupal.settings....
		
apachesolr_autocomplete.js (line 6, col 2)

The problem disappears if I change "Autocomplete widget to use:" to "Drupal core autocomplete widget".

It looks like "apachesolr_autocomplete.js" tries to use the jquery.js/jquery.autocomplete.js before it has loaded.

We need to just change the order the files get loaded in apachesolr_autocomplete_init()

Comments

Bill Choy’s picture

Issue summary: View changes

Here is the fixed version. Just moving the drupal_add_js()

DELETE

/**
* Implementation of hook_init().
*/
function apachesolr_autocomplete_init() {
drupal_add_css( drupal_get_path('module', 'apachesolr_autocomplete') . '/apachesolr_autocomplete.css');

// If using custom JS widget, include files and settings.
if (apachesolr_autocomplete_variable_get_widget() == 'custom') {
// Add custom autocomplete files
drupal_add_css( drupal_get_path('module', 'apachesolr_autocomplete') .'/jquery-autocomplete/jquery.autocomplete.css');
drupal_add_js(drupal_get_path('module', 'apachesolr_autocomplete') .'/jquery-autocomplete/jquery.autocomplete.js');
drupal_add_js(drupal_get_path('module', 'apachesolr_autocomplete') .'/apachesolr_autocomplete.js');
// Specify path to autocomplete handler.
drupal_add_js(array('apachesolr_autocomplete' => array('path' => url('apachesolr_autocomplete'))), 'setting');
}
}
DELETE

Corrrected fix in #5

Bill Choy’s picture

Title: TypeError: $(...).autocomplete is not a function in ctool modal window (multivariate) » Javascript Load order
Bill Choy’s picture

Bill Choy’s picture

Background:

Happens when using multivariate 6.x-2.x-dev contrib module (nice use of ctools). While creating a mutlivate content type and try to add a 'URL Path' in 'Run Conditions', it will spit out the above JS Error when it opens a Ctools Modal Window.

Bill Choy’s picture

StatusFileSize
new499 bytes

It turn out that the Drupal.behaviour just need the JQuery Wrapper.