Revision #6 has been created by François Gannaz on Oct 18, 2013, 3:25:11 AM with the memo:
Fixed CJava*s*cript (PHP is case sensitive on classes but not on functions, pfff)
« previous (#5)
Changes
Title
unchanged
Javascript and AJAX with Yii
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
javascript, AJAX
Content
changed
[...]
~
```php
echo $form->hiddenField($model, 'userId');
$quotedUrl = CJavasScript::encode($this->createUrl(array('user/complete')));
$params = array(
'name' => "userComplete",[...]
'ajaxUrl' => $this->createUrl('complete', 'id' => $model->id,
);
Yii::app()->clientScript->registerScript('variables', 'var myApp = ' . CJavasScript::encode($vars) . ';');
```~
Aside [CJava
sScript::encode()], the method [CJava
sScript::quote()] can also be useful.
~
```php
$url = $this->createUrl('app/ajaxProcessor');
$cs->registerScript('var1', "var myUrl = '" . $url . "';"); // can break with some URLs
$cs->registerScript('var1', "var myUrl = '" . CJava
sScript::quote($url, true) . "';");
```~
### 3. Final words[...]