registerCssFile() OK,but registerScriptFile() failed

I made a very simple widget, but still encountered some problems

I have the following file structure

int the components dir, there are



views/assets/js/(…some js files I want to import)

views/assets/css/(… some css files I want to import)

And now I want to register a css file in the css dir and a js file in the js dir in my widget code

Here is part of the widget code, extended from CWidget class

in the run() method


$this->baseUrl=CHtml::asset(dirname(__FILE__).DIRECTORY_SEPARATOR.'views/assets'); //设置baseUrl,为views/assets


        $cs->registerScriptFile($this->baseUrl.DIRECTORY_SEPARATOR.'js/javascript.js');//register js file

        $cs->registerCssFile($this->baseUrl.DIRECTORY_SEPARATOR.'css/stylesheet.css');//register css file

However, strange things happened.

The css file is successfully registered and it is also published in the asset directory, where jquery core scripts reside, the dir under alias "application".

But the js file failed to register. How could it happen?

The result is :



there is stylesheet.css, which is what I want to register

and there is an empty js dir, but no files in it.

if I directly publish the asset folder using CAssetManager’s publish method, it is ok.

You must miss something, because CHtml::asset() does exactly the same (click on show to see the source).

yeah, thanks for reminding!