3

I need <script> in header to define a JavaScript variable (var dates={...};) which is to be used from a .js script.

It should be preferably in header and not inside jQuery(function($){...}) not to hide the variable from using it by my .js script.

Can it be done in any other way than modifying the layout?

4

1 に答える 1

2

私は通常これを行います:

Yii::app()->clientScript->registerScript('my vars','
    var myFirstVar="something";
    var myUrl="' . CController::createUrl("controller/action") . '";
    ,CClientScript::POS_HEAD);
于 2013-07-02T16:12:09.363 に答える