SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting javascripts to work

    Having trouble hetting script to work even though I thought I had them loading correctly.
    I load jQuery in the functions file
    PHP Code:
    function my_scripts() {
        if (!
    is_admin()) {
            
    wp_deregister_script('jquery');
            
    wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"), false'1.6.4'true);
            
    wp_enqueue_script('jquery');
        }
    }
    add_action('init''my_scripts'); 
    Even though it should load in the footer, it does not. <?php wp_footer(); ?> and <?php wp_head(); ?> are in the correct place in the footer.php and header.php files.
    I'm thinkink a plug-in I'm using is causing the problem (wp-events calendar) since it's javascript files load in the head section also.

    There is really no conflict or problem until I try to use the jQuery accordion and a modal box on one of the pages. The scripts for this page are loaded thru the functions file also
    PHP Code:
    add_action('wp_print_scripts''enqueueMyScripts');
    function 
    enqueueMyScripts(){
        if( 
    is_page('sample-page') ) {
            
    wp_enqueue_script'accordion'get_bloginfo('template_url') . '/js/jquery.dimensions.js', array('jquery'), '3.2.1'true);
            
    wp_enqueue_script'accordion-slide'get_bloginfo('template_url') . '/js/jquery.accordion.js', array('jquery'), '3.2.1'true);
            
    wp_enqueue_script'accordion-custom'get_bloginfo('template_url') . '/js/accordion-custom.js', array('jquery'), '1.0'true);
            
    wp_enqueue_script'modal'get_bloginfo('template_url') . '/js/modal-window.js'false'1.0'true);
       }

    The accordion doesn't work with Jquery loaded in the head section, but works if jQuery is loaded again in the footer for this page. This loads the same file twice which I don't want.

    The modal window works whether the script is loaded in the head section or after the footer, however the events calendar popup quits working. The overlay works but the Thickbox popup does not.

    I'm thinking it is just a matter of getting the scripts to load in the right order but having a heck of a time doing it.

    Plugins I am using:
    Events Calendar
    C-Forms

    Scripts:
    jQuery Modal window
    jQuery accordion

  2. #2
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since there doesn't seem to be a good answer to my problem, I found a temporary solution.
    Seems there is a conflict between the event calendar scripts and the accordion scripts, so I just removed the calendar from the sidebar on that page and all is well.
    Am looking for an accordion plugin that will not conflict but they all seem to be for menus.


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
  •