SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru Todd Temple's Avatar
    Join Date
    Mar 2005
    Location
    Tennessee
    Posts
    797
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery noConflict Question

    I have a site that includes the Nivo Slider. The site is http://www.omegatechserv.com and I think the issue is a jQuery conflict. So I have added the noConflict portion shown below, but the slider is still not working properly. Can anyone tell me how to fix this issue? I would appreciate any and all help as I do not know how to write or edit jQuery.

    Code:
    <script type="text/javascript">
    	$.noConflict();
    	$(window).load(function() {			
    		$('#slider').nivoSlider({
    			pauseTime:<?php echo get_option_tree('slider_pause'); ?>,
    			effect:<?php echo "'".get_option_tree('slider_effect')."'"; ?>,
    			animSpeed:<?php echo get_option_tree('slider_speed'); ?>,
    			directionNav:<?php echo get_option_tree('slider_direction_nav'); ?>
    		});			
    	});
    	function prettyPhoto() {
    		$(".gallery a[rel^='gallery']").prettyPhoto({animation_speed:'normal',theme:'pp_default',deeplinking:false,slideshow:3000,opacity: 1,social_tools:true});
    	}	
    	prettyPhoto();
    	</script>
    Thanks in advance!
    Todd
    Todd Temple > T2 Design

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    When you use noConflict it detaches jQuery from $() so that $() can be used by other scripts.

    If you want to use noConflict AND continue using $ to refer to jQuery then wrap your jQuery code inside an anonymous function:

    Code:
    jQuery.noConflict();
    (function($) {
    //your code goes here and can use $() as a reference to jQuery
    })(jQuery);
    
    // the code using $() to reference something else goes here
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,055
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    When I look at your page in the console (how do I do that?) I see the following errors:

    Code:
    Uncaught TypeError: Object [object Object] has no method 'live' jquery.nivo.slider.pack.js?ver=3.7.1:35
    Uncaught TypeError: undefined is not a function jquery.nivo.slider.pack.js?ver=3.7.1:35
    You are including jQuery v1.9.1 in your page from which the .live() method has been removed.
    Try including an earlier jQuery version instead (such as 1.7) and see if this helps.

    I've moved this thread to the JS forum.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Pullo View Post
    You are including jQuery v1.9.1 in your page from which the .live() method has been removed.
    References to .live have been removed from Nivo Slider as well so rather than going with an earlier version of jQuery it might be better to go with a later version of Nivo Slider.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,055
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by felgall View Post
    References to .live have been removed from Nivo Slider as well so rather than going with an earlier version of jQuery it might be better to go with a later version of Nivo Slider.
    Indeed.
    This is a much better solution.
    Thanks for pointing that out, felgall.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •