Hello All,
I’ve a problem with EScriptBoost and CCaptcha.
I’m designed a form using CActiveForm and added some fields and also a captcha. EScriptBoost extension I’ve also setup. Now the problem is a javascript error. The error console shows undefined “dummy”. Means there is a dummy variable without pre declaration and initialization.
I found that javascript variable in CCaptcha. CCaptcha is registering script with content "dummy". Have a look here
/**
* Registers the needed client scripts.
*/
public function registerClientScript() {
$cs = Yii::app()->clientScript;
$id = $this->imageOptions['id'];
$url = $this->getController()->createUrl($this->captchaAction, array(CCaptchaAction::REFRESH_GET_VAR => true));
$js = "";
if ($this->showRefreshButton) {
/**
* Here CCaptcha Registering 'dummy'. Why I'm not getting?
*/
$cs->registerScript('Yii.CCaptcha#' . $id, 'dummy');
$label = $this->buttonLabel === null ? Yii::t('yii', 'Get a new code') : $this->buttonLabel;
$options = $this->buttonOptions;
if (isset($options['id']))
$buttonID = $options['id'];
else
$buttonID = $options['id'] = $id . '_button';
if ($this->buttonType === 'button')
$html = CHtml::button($label, $options);
else
$html = CHtml::link($label, $url, $options);
$js = "jQuery('#$id').after(" . CJSON::encode($html) . ");";
$selector = "#$buttonID";
}
if ($this->clickableImage)
$selector = isset($selector) ? "$selector, #$id" : "#$id";
if (!isset($selector))
return;
$js.="
jQuery('$selector').live('click',function(){
jQuery.ajax({
url: " . CJSON::encode($url) . ",
dataType: 'json',
cache: false,
success: function(data) {
jQuery('#$id').attr('src', data['url']);
jQuery('body').data('{$this->captchaAction}.hash', [data['hash1'], data['hash2']]);
}
});
return false;
});
";
/*
* Here registering the final script with same id as above
*/
$cs->registerScript('Yii.CCaptcha#' . $id, $js);
}
Why not EScriptBoost re-assigns when found same script id.
Finally I removed the EScriptBoost extension to work.
Thanks a lot in advance