getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype'); sfContext::getInstance()->getResponse()->addJavascript('ajax_history'); if (isset($options['frequency']) && $options['frequency'] > 0) { return _build_observer_wh('Form.Element.Observer', $field_id, $options); } else { return _build_observer_wh('Form.Element.EventObserver', $field_id, $options); } } /** * _build_observer with history */ function _build_observer_wh($klass, $name, $options = array()) { if (!isset($options['with']) && $options['update']) { $options['with'] = 'value'; } $callback = remote_function($options); $updator = "_ajax_updator_" . time(); $javascript = " function ".$updator.'(value) {'.$callback.'} history_callback_function = '.$updator.'; '; $javascript .= 'new '.$klass.'("'.$name.'", '; if (isset($options['frequency']) && $options['frequency'] > 0) { $javascript .= $options['frequency'].", "; } $javascript .= "function(element, value) {change_location('$name', value); "; $javascript .= $updator.'(value)});'; return javascript_tag($javascript).''; }