更改布局时,Select2 jquery函数未定义

时间:2014-09-18 08:13:50

标签: javascript jquery yii jquery-select2

我在yii中更改了布局文件,现在识别了select2函数的问题。 enter image description here 我检查了源代码 - 两种情况看起来都相同。在这两个中都存在select2.js:<script type="text/javascript" src="/app3/assets/b92019fc/select2.js"></script>

出现问题的源代码:

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/ico" href="/app2/img/favicon.ico">

 some css files are here... 

<script type="text/javascript" src="/app3/assets/df744518/jquery.js"></script>
<script type="text/javascript" src="/app3/assets/df744518/jquery.ba-bbq.js"></script>
<script type="text/javascript" src="/app3/assets/df744518/jui/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/app3/assets/df744518/jquery.yii.js"></script>
<script type="text/javascript" src="/app3/assets/b92019fc/select2.js"></script>
<title>tarex. Page3</title>

 some css files are here... 

<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script> 
    <script type="text/javascript" src="assets/35648952/jquery.yii.js"></script>
<script type="text/javascript">
jQuery(function($) {    
    jQuery('body').on('change','#_lang',function(){jQuery.yii.submitForm(this,'',{});return false;}); 
 jQuery('body').on('change','#Cityes_Name',function(){jQuery.yii.submitForm(this,'',{});return false;});
}); 
</script>
<script language='javascript'>       
            var RoleId=1; 
            var UserName='admin'; 
            var UserId='36'; 
            var OrganizationId='7'; 
            var Language='ru'; 
            //console.log('Language '+Language);</script>
</head>

没有问题的源代码:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="language" content="en" /> 
<link rel="shortcut icon" type="image/ico" href="/app2/img/favicon.ico">

<script language='javascript'>       
            var RoleId=1; 
            var UserName='admin'; 
            var UserId='36'; 
            var OrganizationId='7'; 
            var Language='ru'; 
            //console.log('Language '+Language);</script>
    <!-- blueprint CSS framework --> 
 some css files are here... 

<script type="text/javascript" src="/app3/assets/df744518/jquery.js"></script>
<script type="text/javascript" src="/app3/assets/df744518/jquery.ba-bbq.js"></script>
<script type="text/javascript" src="/app3/assets/df744518/jquery.yii.js"></script>
<script type="text/javascript" src="/app3/assets/b92019fc/select2.js"></script>
<title>Главное меню</title>

</head>

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

您正在应用jQuery几次。仅使用Yii::app()->clientScript->registerCoreScript('jQuery')

加载jQuery一次