I have a fully managed website, so lately I had to research delegation methods. I found out that .live and .delegate are deprecated, and the new function is .on.
If I dynamically load a web page into a section on the current page (AJAX), for example:
<html> <head> <script src="jquery.js"> </script> <script> function ajaxTest() { $('#content').load('test.php'); } </script> <script type="text/javascript"> $(function(){ $(document).on("click", "#map", function(){ alert("it has been loaded"); }); }); </script> </head> <body> <div id="content"> <button onClick="ajaxTest()" value="Click Me"> This is to be clicked </button> </div> </body> </html>
where test.php looks like
<html> <head> </head> <body> <div id="map">THIS IS THE MAP</div> </body> </html>
Then I can click on the words βTHIS MAPβ and it really shows a warning. The problem I ran into is not to do:
$(document).on("**click**", "#map", function(){
I need something more line by line:
$(document).on("**load**", "#map", function(){
This does not work explicitly, so I'm wondering if something like this can. The whole reason I even ask about this is because on some pages, instead of just βTHIS MAKAβ in the map unit, I have a google map or swf object or something else. Any help would be appreciated.
If you just want to answer how to load a Google map into a division that does not exist yet, this will also be useful;)