Helping loading a script without calling jquery before it

Discussion in 'jQuery' started by sahmothers.com, Aug 18, 2010.

  1. #1
    The site is http://s91532.gridserver.com and no matter where you click, it brings down our javascript menu from the top.

    I have removed the offending jquery which was an older version of js, but now it wont launch the drop down menu. I am now just calling the site.js which is the code below:

    jQuery(document).ready(function(){
    $('p#minguide-link a').click(function(){
    if ($('#index-wrapper').is(':hidden')) {
    $('#index-wrapper').slideDown('medium');
    $('p#minguide-link a').addClass('down');
    return false;
    } else {
    $('#index-wrapper').slideUp('medium');
    $('p#minguide-link a').removeClass('down');
    return false;
    }
    });

    var group_width = $('li#nav_groups ul').width();
    var group_adj = ((group_width*-1)/2)+79;
    var care_width = $('li#nav_care--serve ul').width();
    var care_adj = ((care_width*-1)/2)+79;
    var sermon_width = $('li#nav_sermons ul').width() + 2;
    var sermon_adj = ((sermon_width*-1)/2)+79;

    $('li#nav_groups.current ul').css({"left":"auto", "margin-left":group_adj});
    $('li#nav_care--serve.current ul').css({"left":"auto", "margin-left":care_adj});
    $('li#nav_sermons.current ul').css({"left":"auto", "margin-left":sermon_adj});
    });

    With that alone being called nothing happens. It seems that it is now fixed in IE from what I can tell. But the menu doesn't drop down because jquery is not called before this script.

    I am not sure or not but I found this site and this workaround -

    try {
    $("#myselector").click (function () {}); //my jQuery code here
    } catch (e) {
    console.log (e.message); //this executes if jQuery isn't loaded
    }

    Now how do I get site.js to be called correctly so the menu drops down correctly.
     
    sahmothers.com, Aug 18, 2010 IP
  2. sahmothers.com

    sahmothers.com Well-Known Member

    Messages:
    2,389
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    135
    #2
    I figured it out.

    Thanks all!
     
    sahmothers.com, Aug 18, 2010 IP