WP Framework Forums » Troubleshooting

Looking to add other .js but cannot get it to load properly

(5 posts)
  • Started 2 weeks ago by kevins
  • Latest reply from ptahdunbar
  1. kevins
    Member

    Trying to load 2 different .js for a couple of themes I am working on, but cannot get the js to load ?

    I have tried within the framework.php where the screen.js is loaded, and also in the header where you can normally call js at.

    Neither have worked for me.

    Posted 2 weeks ago #
  2. ptahdunbar
    Framework Overlord

    which version do you have?

    In any case, add this to your theme-functions.php:

    function js_scripts(){
    echo '< script type="application/javascript" language="javascript" src="'. get_bloginfo('template_directory') . '/assets/screen.js' .'">';
    }
    add_action('wp_head', 'js_scripts');

    remove spaces from script tag

    Posted 2 weeks ago #
  3. ptahdunbar
    Framework Overlord

    I found a bug in theme.php that pointed to the wrong path for screen.js.

    Here's the fix: replace this with the current one in theme.php

    // Javascript + jQuery
    function js_scripts() {
    wp_enqueue_script( 'theme_scripts', THEMEJS .'/screen.js', array( 'jquery' ) );
    }
    add_action( 'init', 'js_scripts' );

    Posted 4 days ago #
  4. kevins
    Member

    I am still using 0.2.2 and dont have the theme.php that is in with 0.3 - I have still tried a few things (and already fixed the wrong path error previously) but still cannot get any js to load. I am trying to use the s3Slider as follows:

    <script type="text/javascript" src="assets/js/jquery.js"></script>
    <script type="text/javascript" src="assets/js/s3Slider.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    $('#slider1').s3Slider({
    timeOut: 4000
    });
    });
    </script>

    I have tried everywhere and each way that I know how with no luck. I have also attempted using the LavaLamp YUI js with the same issue... no luck....

    Posted 3 days ago #
  5. ptahdunbar
    Framework Overlord

    Alright, this should fix your problem:

    in screen.js paste this in:

    jQuery(document).ready(function()
    {
    jQuery('#slider1').s3Slider({
    timeOut: 4000
    });

    });

    and in theme-functions.php, paste this in:

    // Load s3 Slider
    function js_scripts() {
    wp_enqueue_script( 'js_scripts', get_stylesheet_directory_uri() .'/assets/js/s3Slider.js', array( 'jquery' ) );
    }
    add_action( 'init', 'js_scripts' );

    The problem you had was because you need to use "jQuery" instead of the dollar alias.

    Posted 3 days ago #

RSS feed for this topic

Reply

You must log in to post.