Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery's .on function doesn't seem to like 'load' event
    primarykey
    data
    text
    <p>I have a completely ajax driven website, so lately I've had to research delegation techniques. I've learned that .live and .delegate have been deprecated and the new function to use is .on .</p> <p>If I'm dynamically loading a webpage into a division on the current page (AJAX) like so:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="jquery.js"&gt; &lt;/script&gt; &lt;script&gt; function ajaxTest() { $('#content').load('test.php'); } &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ $(document).on("click", "#map", function(){ alert("it has been loaded"); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;button onClick="ajaxTest()" value="Click Me"&gt; This is to be clicked &lt;/button&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>where test.php looks like</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="map"&gt;THIS IS THE MAP&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I can then click on the words "THIS IS THE MAP" and it does indeed show the alert. The problem I've been having is instead of doing:</p> <pre><code>$(document).on("**click**", "#map", function(){ </code></pre> <p>I need something more along the lines of:</p> <pre><code>$(document).on("**load**", "#map", function(){ </code></pre> <p>It doesn't work obviously, so I'm wondering if something similar might. The whole reason I'm even inquiring about this is because in some pages, instead of having just "THIS IS THE MAP" in the map division, I have a google map or an swf object or something. Any help would be appreciated.</p> <p>If you wanted to just answer how to load a google map into a division that doesn't exist yet, that would be helpful too ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload