我在 themes / bootstrap / views / layouts / main.php
的顶部添加了此代码Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/custom.js');
在我的HTML中确实显示
<head>
<script type="text/javascript" src="/dev2/js/custom.js"></script>
</head>
并在custom.js
文件中我有这个
jQuery(function($) {
alert('test');
}
页面加载时,我没有收到任何警告。这些文件确实存在于正确的目录中,我没有得到任何firebug警告。由于某种原因我使用registerScriptFile
手动包含的所有JS文件都不起作用。我的所有插件都没有包括工作。有什么想法吗?
答案 0 :(得分:0)
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/custom', CClientScript::POS_HEAD);
脚本中的和错误:
jQuery(function($) {
alert('test');
});
必须工作
答案 1 :(得分:0)
你可以试试这个:
$(document).ready(function(){
alert('hello');
// Enter code here
});
你的custom.js中的。