SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    May 2012
    Posts
    996
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post 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

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

    toOtherpage.php

    Code:
         .........including some js file here ........
         ...................
         ...................
         <script type="text/javascript">
             function initialize(){
                 some statement here .......
                 .............
                 ............
            }
                   
            google.maps.event.addDomListener(window, 'load', initialize);
             
        </script>

  2. #2
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,256
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    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.

  3. #3
    SitePoint Guru
    Join Date
    May 2012
    Posts
    996
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, you mean like this

    $('#link').click(function(){
    $('container').load('toOtherpage.php');
    initialize();
    });
    I tried already but it doesn't work.

  4. #4
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,256
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    No I mean like this:
    Code JavaScript:
    $('container').load('toOtherpage.php', function(){
        initialize();
    });

  5. #5
    SitePoint Guru
    Join Date
    May 2012
    Posts
    996
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    No I mean like this:
    Code JavaScript:
    $('container').load('toOtherpage.php', function(){
        initialize();
    });

    still doesn't work

  6. #6
    SitePoint Guru
    Join Date
    May 2012
    Posts
    996
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    No I mean like this:
    Code JavaScript:
    $('container').load('toOtherpage.php', function(){
        initialize();
    });


    Hi your code is working, thank you, i misplaced my google js,that's why in my first attempt was failed....


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
  •