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
Comment #1
Bill Choy commentedHere 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
Comment #2
Bill Choy commentedComment #3
Bill Choy commentedComment #4
Bill Choy commentedBackground:
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.
Comment #5
Bill Choy commentedIt turn out that the Drupal.behaviour just need the JQuery Wrapper.