$(function() {
$('#dialog').click(function() {
alert("hello");
});
});
$('select').yaselect();
I am genuinely confused about how javascript script inclusion works.
So the click handler for the dialog works fine.
But the yaselect does not. I get $(“select”).yaselect is not a function
So jQuery seems to work, but the yaselect somehow not. It is included in the head section of the file though.
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/libs/jquery-1.7.2.min.js?"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/libs/jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/libs/jquery.yaselect.min.js"></script>
However, the yii framework somehow includes jquery again later in the head section:
<script type="text/javascript" src="/assets/ab20866e/jquery.js"></script>
<script type="text/javascript" src="/assets/ab20866e/jquery.yiiactiveform.js"></script>
I understand this might be a problem, however I took over this code, I am new to yii and so am confused about what to do.
http://www.yiiframework.com/wiki/311/assetmanager-clearing-browser-s-cache-on-site-update/
This appears to solve the problem.
In Yii framework, you can use the AssetManager to handle static resources. If they then get referenced through the AssetManager instead of directly including them in the html source files, the yii framework takes care that resources are included once only.
Nice 🙂