Do I need 2 JQueries?

Guys,

I have a mega menu build over mootools and other things loaded this way:


Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/media-system-core.js", CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/media-system-mootools-core.js", CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/media-system-mootools-more.js", CClientScript::POS_HEAD); 

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/jat3-core.js", CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/mega.rjd.js", CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/menu-mega.js", CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/media-system-caption.js", CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/jquery-1.7.1.js", CClientScript::POS_HEAD);



It works fine, but if I do this:


Yii::app()->clientScript->registerCoreScript('jquery');

…which is what Yii will do if I use forms, and then I get this error:

Object [object Object] has no method ‘getElements’

No matter of what. I’ve changed the load order and I already tried this also:


Yii::app()->clientScript->coreScriptPosition = CClientScript::POS_END;

Among other thigs, but my question is: do I really need to have another JQuery loaded twice? The version I’m using (1.7.1) is exactly the same used in the last version of Yii, so why loading another one?

Thanks!

it is because Yii does not know you have already loaded other jQuery instance.

remove this line:

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/jquery-1.7.1.js", CClientScript::POS_HEAD);

and add

Yii::app()->clientScript->registerCoreScript(‘jquery’);

every component which rely on jQuery use this core script and registers it this way, so if you also use this way - it will be loaded only once.

Already tried. I did this and many more, but registerCoreScript just add them at the top (head) or end of html and JQuery+Mootools only works when it is in the middle. Trying many configurations of JQuery & MooTols. The only possible solution I see is to not let Yii add its JQuery in the code. Is there a way to supress the registerCoreScript(‘jquery’) that happens automagically when it needs?

Thanks!

Solved via config\main.php:


        'clientScript'=>array(

          'packages'=>array(

            'jquery'=>array(

              'baseUrl'=>'/www.payingless.org/site/web/',

              'js'=>array(  'js/media-system-core.js'

                          , 'js/media-system-mootools-core.js'

                          , 'js/media-system-mootools-more.js'

                          , 'js/jat3-core.js'

                          , 'js/mega.rjd.js'

                          , 'js/menu-mega.js'

                          , 'js/media-system-caption.js' 

                          , 'js/jquery-1.7.1.js'

                          , 'js/jquery.masonry.js'

                          , 'js/jquery.mediaqueries.js'

                         ),

            )

          ),

        ),