Skip to content
Snippets Groups Projects
Commit 975ab563 authored by berend's avatar berend Committed by haiiro.simeji
Browse files

Issue 315236: GMap View, Exposed Filters and the error "Javascript is required...

Issue 315236: GMap View, Exposed Filters and the error "Javascript is required to view this map" upon AJAX update
parent 3651546a
No related branches found
No related tags found
No related merge requests found
...@@ -1310,6 +1310,47 @@ function gmap_views_plugins() { ...@@ -1310,6 +1310,47 @@ function gmap_views_plugins() {
); );
} }
/**
* Implementation of hook_views_pre_render().
*/
function gmap_views_pre_render(&$view) {
static $gmap_processed;
// Add js only for gmap style views with ajax and not already processed.
if (($view->plugin_name != 'gmap' && $view->plugin_name != 'gmapextended')
|| !$view->use_ajax || $gmap_processed) {
return;
}
// Mark the view as already processed.
$gmap_processed = TRUE;
// Add js with new views callback.
drupal_add_js(drupal_get_path('module', 'gmap') . '/js/gmap_views_ajax.js', array('group' => JS_DEFAULT));
}
/**
* Implementation of hook_views_ajax_data_alter().
*/
function gmap_views_ajax_data_alter(&$commands, $view) {
// Add js callback only with gmap style plugins and with ajax.
$plugin_styles = array ($view->plugin_name);
foreach ($view->display as $display)
$plugin_styles[] = $display->display_options['style_plugin'];
if (! (in_array ('gmap', $plugin_styles) || in_array ('gmap', $plugin_styles)))
return;
// Find the JQuery selector for the view's wrapper in the DOM
$target = '';
foreach ($commands as $command) {
if ($command['command'] == 'insert') {
$target = $command['selector'];
}
}
$command = array('command' => 'gmapAjaxViewsFix', 'target' => $target);
// Save settings.
$js = drupal_add_js(NULL, array('scope' => 'header'));
$command['settings'] = $js['settings']['data'];
$commands[] = $command;
}
function theme_gmap_views_ui_gmapextended($variables) { function theme_gmap_views_ui_gmapextended($variables) {
$form = $variables['form']; $form = $variables['form'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment