ThemeShaper Forums » Thematic

[closed]

The jQuery Demon

(8 posts)
  • Started 3 years ago by laughhearty
  • Latest reply from joperron
  • This topic is resolved
  1. Okay,
    I've been digging around on the forum for hours. I've found so much helpful leads but nothing is getting my jQuery anythingSlider to work.

    I'm making a custom child theme using Thematic.
    Here's my functions.php code:

    function my_init_method() {

    //use google's jquery
    if (!is_admin()){
    wp_deregister_script( 'jquery' );
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
    wp_enqueue_script('jquery');
    wp_enqueue_script('yourscript', get_bloginfo('stylesheet_directory') . '/js/jquery.anythingslider.js');
    wp_enqueue_script('yourscript', get_bloginfo('stylesheet_directory') . '/js/jquery.easing.1.2.js');

    }

    }

    add_action('template_redirect', 'my_init_method');

    function my_in_head(){ ?>

    <script type="text/javascript">
    //<![CDATA[

    jQuery.noConflict();
    jQuery(document).ready(function($) { //tells WP to recognize the $ variable

    //paste your jquery code here
    function formatText(index, panel) {
    return index + "";
    }

    $(function () {

    $('.anythingSlider').anythingSlider({
    easing: "easeInOutExpo", // Anything other than "linear" or "swing" requires the easing plugin
    autoPlay: false, // This turns off the entire FUNCTIONALY, not just if it starts running or not.
    delay: 3000, // How long between slide transitions in AutoPlay mode
    startStopped: false, // If autoPlay is on, this can force it to start stopped
    animationTime: 600, // How long the slide transition takes
    hashTags: true, // Should links change the hashtag in the URL?
    buildNavigation: true, // If true, builds and list of anchor links to link to each slide
    pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover
    startText: "Go", // Start text
    stopText: "Stop", // Stop text
    navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
    });

    $("#slide-jump").click(function(){
    $('.anythingSlider').anythingSlider(6);
    });

    });

    }); //end document ready functions

    /* ]]> */
    </script>

    <?php }
    add_action('wp_head', 'my_in_head');

    Posted 3 years ago #
  2. you are included the css for the slider right?

    i haven't tested this, but you could try...

    //ENQUEUE SCRIPTS
    function my_init() {
    if (!is_admin()) {
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', false, '1.4.2', true);
    wp_enqueue_script('jquery');
    //anything slider
    wp_enqueue_script('slider', get_bloginfo('stylesheet_directory') . '/js/jquery.anythingslider.js', array('jquery'), '1.5.2', true );
    //easing
    wp_enqueue_script('easing', get_bloginfo('stylesheet_directory') . '/js/jquery.easing.1.2.js', array('jquery'), '1.2', true );
    }
    }
    add_action('init', 'my_init');

    then...

    //LOAD SLIDER
    function my_slider() {
    
    <script type="text/javascript">
    
    jQuery(document).ready(function($) {
    
    $(function () {
    $('.anythingSlider').anythingSlider({
    easing: "easeInOutExpo", // Anything other than "linear" or "swing" requires the easing plugin
    autoPlay: false, // This turns off the entire FUNCTIONALY, not just if it starts running or not.
    delay: 3000, // How long between slide transitions in AutoPlay mode
    startStopped: false, // If autoPlay is on, this can force it to start stopped
    animationTime: 600, // How long the slide transition takes
    hashTags: true, // Should links change the hashtag in the URL?
    buildNavigation: true, // If true, builds and list of anchor links to link to each slide
    pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover
    startText: "Go", // Start text
    stopText: "Stop", // Stop text
    navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
    });
    
    $("#slide-jump").click(function(){
    $('.anythingSlider').anythingSlider(6);
    });
    
    });
    
    </script>
    
    }
    add_filter('thematic_after', 'my_slider');

    then add the css to a section in your stylesheet

    let me know how you get on

    Posted 3 years ago #
  3. That didn't work.
    The odd thing about the slider is that most of the jQuery seems to be working. I'm getting the forward and backwards buttons, the thumb navigation etc. The only problem is that when I click on anything the slider doesn't move, nor does it move automatically when page is loaded. I've got this slider going on other WP sites, live and on my local machine. It's just not working in this Thematic child theme.

    Posted 3 years ago #
  4. I also noticed that when I click on the thumbnav, the url changes in the browser address window but the image does not.

    Posted 3 years ago #
  5. OMG!
    Duh.

    This is where the problem lay:

    Instead of:

    if (!is_admin()){
    	wp_deregister_script( 'jquery' );
    	wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
    	wp_enqueue_script('jquery');
    	wp_enqueue_script('jquery.anythingslider', get_bloginfo('stylesheet_directory') . '/js/jquery.anythingslider.js');
    	wp_enqueue_script('jquery.easing.1.2', get_bloginfo('stylesheet_directory') . '/js/jquery.easing.1.2.js');

    I had:

    if (!is_admin()){
    	wp_deregister_script( 'jquery' );
    	wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
    	wp_enqueue_script('jquery');
    	wp_enqueue_script('yourscript', get_bloginfo('stylesheet_directory') . '/js/jquery.anythingslider.js');
    	wp_enqueue_script('yourscript', get_bloginfo('stylesheet_directory') . '/js/jquery.easing.1.2.js');
    
    	}
    
    }

    Observe the ridiculous inclusion of "yourscript". Yeah, that really helps...

    Hours, I've spent trying to figure this out. Hours.

    Posted 3 years ago #
  6. i just noticed this thread and was going to point the 'yourscript' problem out. likely WP was only enqueing 1 of your 2 scripts and not both of them since you had named them the same thing. i've been in your shoes. sometimes things take me hours one night and after sleeping on it i can figure it out in 10 minutes. sometimes a break and fresh eyes is the best thing.

    Posted 3 years ago #
  7. Exactly,
    That's one worn out pair of shoes!
    How do I add an avatar picture. I could find an upload button in my profile?

    Thanks

    Posted 3 years ago #
  8. Get an avatar at gravatar.com :)

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.