I have a strange problem with Yii & Jquery:
When I open a page which uses ajax/jquery on localhost Yii does automatically add asset include calls to the of the page:
<link rel="stylesheet" type="text/css" href="/PATH/assets/f72b359d/style.css" />
<script type="text/javascript" src="/PATH/assets/2e442e1a/jquery.js"></script>
<script type="text/javascript" src="/PATH/assets/2e442e1a/jquery.cookie.js"></script>
However when I run same code on the server Yii does not do it hense no Jquery available.
I'd appreciate if someone could direct to a way to solve it.
It seems like you're not registering jQuery in the correct way. You must add the following line in /protected/views/layout/main.php
before </head>
tag:
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
It will load jQuery automatically. Remember, if the YII_DEBUG flag is on it will load non-minified version, when deactivated (on production) it will load minified version. Hope this will fix your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With