2012-02-14 13 views
0

私のウェブサイトにthis particular appを統合しようとしています。競合:子ページを読み込むときにJavaScriptが機能しない

メインページにコンテンツとして読み込むと、メインページのjqueryメニューが機能しなくなります。ここに矛盾があるようです。ここ はchildpageからスクリプトである:ここでは

<script type='text/javascript'> 
    $(function() { 
    var bucharest = new google.maps.LatLng(44.436055, 26.097593), 
     pointToMoveTo, 
     first = true, 
     curMarker = new google.maps.Marker({}), 
     $el; 

    var myOptions = { 
     zoom: 13, 
     center: bucharest, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 

    var map = new google.maps.Map($("#map_canvas")[0], myOptions); 

    $("#locations li").mouseenter(function() { 

    $el = $(this); 

    if (!$el.hasClass("hover")) { 

     $("#locations li").removeClass("hover"); 
     $el.addClass("hover"); 

     if (!first) { 

     // Clear current marker 
     curMarker.setMap(); 

     // Set zoom back to Bucharest level 
     // map.setZoom(10); 
     } 

     // Move (pan) map to new location 
     pointToMoveTo = new google.maps.LatLng($el.attr("data-geo-lat"), $el.attr("data-geo-long")); 
     map.panTo(pointToMoveTo); 

     // Add new marker 
     curMarker = new google.maps.Marker({ 
      position: pointToMoveTo, 
      map: map, 
      icon: "images/marker.png" 
     }); 

     // On click, zoom map 
     google.maps.event.addListener(curMarker, 'click', function() { 
     map.setZoom(14); 
     }); 

     // Fill more info area 
     $("#more-info") 
     .find("h2") 
      .html($el.find("h3").html()) 
      .end() 
     .find("p") 
      .html($el.find(".longdesc").html()); 

     // No longer the first time through (re: marker clearing)   
     first = false; 
    } 

    }); 

    $("#locations li:first").trigger("mouseenter"); 

}); 

は、メインページのメニューのためのスクリプトです:

$(document).ready(function() { 
    $("ul#nav li a").addClass("js"); 
    $("ul#nav li a").hover(
     function() { 
     $(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 200); 
     $(this).animate({backgroundPosition:"(0 -5px)"}, 150); 
     }, 
     function() { 
     $(this).animate({backgroundPosition:"(0 -149px)"}, 200); 

     } 
    ); 

}); 

は、これら二つの間に矛盾はありますか? ありがとうございました!

+0

があると思い – fcalderan

+0

の参照を追加します。 Maps Api v3ライブラリ –

答えて

1

私はあなたが任意のJavaScriptのエラーをデモページを投稿したり、報告しなければならない、あなたの最初のdocument.readyにエラー

here : $(function() { 

だから、二document.ready

this one : $(document).ready(function() { 
+0

あなたが言ったことを明確にしてください。私はあなたが何を参照しているのか理解していませんので、2番目のdocument.ready this:$(document).ready(function(){ありがとう! –

+0

2番目はメインページのメニューです – GregM

関連する問題