I'm looking at
http://jquery.bassistance.de/jquery-getting-started.html#rate
where it says:
<SNIP>
A very common problem encountered when loading content by AJAX is
this: When adding event handlers to your document that should also
apply to the loaded content, you have to apply these handlers after
the content is loaded. To prevent code duplication, you can delegate
to a function. Example:
// lets use the shortcut
$(function() {
var addClickHandlers = function() {
$("a.clickMeToLoadContent").click(function() {
$("#target").load(this.href, addClickHandlers);
});
};
addClickHandlers();
});
Now addClickHandlers is applied once when the DOM is ready and then
everytime when a user clicked a link with the class
clickMeToLoadContent and the content has finished loading.
</SNIP>
but I'm not quite getting to this. First I don't understand :
$("#target").load(this.href, addClickHandlers);
because I'm only finding docs for a load function with a single func
argument ... what is this.href doing?
does this mean that addClickHandlers gets called EACH time #target loads?
thanks
Daniel
On 1/13/07, Daniel McBrearty <[EMAIL PROTECTED]> wrote:
> suppose we have some content to a page that gets loaded via AJAX in
> response to some other event ... it looks like this :
>
> <input type="button" id="some_new_button">
>
>
> how do I bind to this, in a simple way?
>
> $(function() {
> $("#some_new_button").click( function() { ... };
> });
>
> doesn't work because the button didn't happen until after the doc loaded ...
>
> any ideas?
>
> --
> Daniel McBrearty
> email : danielmcbrearty at gmail.com
> www.engoi.com : the multi - language vocab trainer
> BTW : 0873928131
>
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/