Jquery conflict in Yii

Hi,

I have a problem, when i try to use a outer script that uses jquery, like fancybox, i have a problem with the following situation…

In the view i render can be found some ajaxLinks that use the jquery embebed code of yii, so the framework loads that part of the code when it needs. As result i have 2 script lines including versions of jquery, and it generates name conflict.


<script type="text/javascript" src="/assets/cc3caafd/jquery.js"></script>

<script type="text/javascript" src="/assets/cc3caafd/jquery.yii.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>



The question is… how can i use both yii ajax methods and my custom jquery code simultaneously without generating conflicts?

My custom jquery code:




<script type="text/javascript">


            $(document).ready(function() {


                $("#thead").show("slide", { direction: "left" }, 1000);                


                var inter = setInterval(changeText, 6000);


                function changeText(){

                    $("#thead").hide("slide", { direction: "right" }, 1000);


                    $.ajax({

                        url: 'nextad',

                        success: function(data) {

                            $('#thead').html(data);

                            $("#thead").show("slide", { direction: "left" }, 1000);

                        }

                    });


                }


            });


        </script>



The code shown above is used to load some news from a database each time have passed 6 seconds.

Any recomendation of a good use of jquery within yii?

Thanks to all

You should be using the following code to request that Yii include the jquery library for the page (when it is rendered)

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

nz

jQuery noConflict() function to give control of the $ variable back to whichever library first implemented it. This function is very useful if you have several JavaScripts frameworks that can be boiled down to $x(…)-style calls.

var $j = jQuery.noConflict();
$j("#myDiv").hide();

This function will reset the $ variable so it’s no longer an alias of jQuery.