Yii Framework Forum: Jquery conflict in Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Jquery conflict in Yii Rate Topic: -----

#1 User is offline   codatavern 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 22-May 09
  • Location:Spain

Posted 20 April 2010 - 09:57 AM

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
0

#2 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 20 April 2010 - 10:20 AM

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users