addDomlistener problem

Hi, I have this problem, I could not load my map in my page if i am using the jquery.load(), but when i directly dial to the url like http://localhost/test/toOtherpage.php
it will load my map.can you help me please what is wrong with my addDomlistener why it will not bind to the window…

Thank you in advance.

here is my code

index.php


  $('#link').click(function(){
     $('container').load('toOtherpage.php');
  });
 .....
 .....
......
  <html>
    <body>
      .......
      ......
      .....
        <div id="container"></div>
  </body>
 </html>


toOtherpage.php


     .........including some js file here ........
     ...................
     ...................
     <script type="text/javascript">
         function initialize(){
             some statement here .......
             .............
             ............
        }

        google.maps.event.addDomListener(window, 'load', initialize);

    </script>




Hi jemz,

The window.load event doesn’t seem to be fired on content that is loaded in with jQuery’s .load() method. As a work-around, you could call the initialize method in a callback on the .load() method.

Hi, you mean like this

$(‘#link’).click(function(){
$(‘container’).load(‘toOtherpage.php’);
initialize();
});

I tried already but it doesn’t work.

No I mean like this:

$('container').load('toOtherpage.php', function(){
    initialize();
});

still doesn’t work :rolleyes:

Hi your code is working, thank you, i misplaced my google js,that’s why in my first attempt was failed…:slight_smile: