title: Jquery event when div is being refreshed
body: <p>right now  , I use <code>jQUery(document).ready</code> to "inject" javascript into a div.</p>
  
  <p>All is fine - but The problem is - that the same div is being refreshed via AJAX - and the JS in that case is not being "re-injected"..</p>
  
  <p>(if someone is interested - the div is actually a "widget in wordpress "widgets admin" area) </p>
  
  <p>My problem is that <code>jQuery(document).ready</code> obviously does not work (the DOM is already "ready") and when I tried <code>jQuery('#divname').ready</code> - I also could not make it work.</p>
  
  <p>I even tried <code>.ajaxComplete()</code> but to no avail ...</p>
  
  <p>I am not sure if it is a general method problem or a specific WP widgets problem..</p>
  
  <p><strong>EDIT I</strong> - for popular request : my script :-)</p>
  
  <pre><code>//php wrapper function here ...
  
  // .. php stuff.
  
      return "
  
      &lt;script type='text/javascript'&gt;
  var map;
  var markersArray = []; // to be used later to clea overlay array
  jQuery(document).ready(function() {
      var lat = ". $lattxt . " ; // .. php variable.
      var lon = ". $lontxt . " ; // .. php variable.
      var marker;
      // ...continue boring google map code 
      };
      map = new google.maps.Map(jQuery('#DivName')[0], myOptions);
     // ...tinue boring google map code 
  
      function placeMarker(location) {
         ///...continue boring google map code 
          }
      }
  
  });&lt;/script&gt;
      &lt;div id='DivName' style='height:200px; width:100%;' &gt;&lt;/div&gt;&lt;br /&gt;
      ";
  </code></pre>
  
  <p>what I am actually doing is creating a DIV and initiating google map.
  The problem is when this "widget" (or "div") is being "saved" via AJAX for options and refreshed - the Javascript is not working (it IS being injected in the code - but not "initiating..)</p>
  
  <p>As I said before - this method is working just fine on the "first" go - but if the div is being refreshed - it is not working anymore even if the div is there and the javascript also there ...</p>
  
  <p>EDIT 1 :</p>
  
  <p>I have found the following links which might or might not help anyone with similar problems :</p>
  
  <p>a short explanation of the problem with a possible solution :
  <a href="http://www.johngadbois.com/adding-your-own-callbacks-to-wordpress-ajax-requests/" rel="nofollow noreferrer">http://www.johngadbois.com/adding-your-own-callbacks-to-wordpress-ajax-requests/</a></p>
  
  <p>Two related questions :</p>
  
  <p><a href="https://stackoverflow.com/questions/1990335/markitup-for-wordpress-widget">markItUp for Wordpress widget</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4844841/jquery-functions-need-to-run-again-after-ajax-is-complete">jQuery Functions need to run again after ajax is complete</a></p>
  
  <p>That being said - I was not yet able to solve my specific problem. if i will I will post complete answer.</p>