0

I'm trying to change a global setting for Drupal's js. I have this on my callback:

$setting['stopWatch']['startTime'] = 4000;
ajax_command_settings($setting, TRUE),

I was wondering how I would reattach this behavior after the ajax call is finished. I have this for my js:

Drupal.behaviors.stopWatch = {
  attach: function (context, settings) {
    $('#stopwatch').stopwatch({startTime: settings.stopWatch.startTime}).stopwatch('start');
  }
};

Also, I'm not sure why startTime isn't available in settings on Drupal.behaviors.stopWatch when I do ajax_command_settings($setting); instead.

1
  • Are you sure the settings function is working properly? I've been trying to use it and it's not been working as advertised for me. Commented Jun 6, 2012 at 8:25

1 Answer 1

1

This will not add variables to settings. Function ajax_command_settings() just creates ajax command, that could be added to commands array. If you want to update settings after view ajax completed you should use something like this:

/**
 * Implements hook_views_ajax_data_alter().
 */
function module_name_tricks_views_ajax_data_alter(&$commands, $view) {
  if ($view->name == 'your_view_name') {
    $setting = module_name_get_settings($view);
    $commands[] = ajax_command_settings($setting, TRUE);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.