Script on being included when using registerScriptFile

Edit: the title was supposed to be "Script NOT being included…"

I have a view where I worked out some jQuery by including it directly in the view with a <script> tag. Everything worked fine. Now I want to move the javascript out into a file. Something seems to be breaking down in the inclusion of the file, however. In the view I have:







In the Firebug Net tab, in the Response, this line appears, as though the file were being included:

<script type="text/javascript" src="/Applications/MAMP/htdocs/transportation/protected/components/js/site_createreservation.js"></script>

However, when I inspect the HEAD in Firebug’s HTML tab, that line is not present, and it’s not listed in the Script tab. The file really does reside at that location, and I’m pretty sure I don’t have any typos in the path. What could be causing this disappearing act?

Any help would be appreciated.

Do you have permissions to read from that location?

Try to put your js files on some publicly available place (e.g. /javascripts/your_file.js)

getPathOfAlias returns a file system PATH, you need a url.


Also, move your js files out of the components folder, it doesn’t make any sense, either put them in your project root in a JS folder, either create extensions and publish their assets, then use the published assets url to reference the asset files(js or css or images).

Thanks. I have tried it with the file in a js directory off my root and using baseUrl, but it still didn’t work, even with hardcoding the url and testing that I could browse to that url and read the javascript in my browser.

Any other ideas? And thanks again.

if you can access the js file directly from your browser, then there is no reason why embeding it won’t work.

What is the full url of your js file?

What do you get when you <?php echo Yii::app()->baseUrl; ?> ?

I just wanted to thank you for the time you put in helping me. I believe the problem has to do with using