Hi, I have a question that puzzles me a lot. I have the following code:
$(document).ready(function() {
   $("#somediv").load("/some/content");
})

The code inserted with AJAX contains two things.
1. A script tag that states things like:
$("#Cancel").click(function(e) {
    e.preventDefault();
    alert("you cancled");
})

2. A div with various elements, like the button with ID "Cancel".

When I click that Cancel button, the alert executes just like I want it to
do. But I can't figure out why?? I mean how can the eventhandler register
correctly. Is the Cancel button from the AJAX call somehow magically insert
into the DOM before the script registering the event executes?
-- 
View this message in context: 
http://old.nabble.com/Why-does-this-work---tp26934213s27240p26934213.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to