Lorenzo Manucci
Lorenzo Manucci

Reputation: 880

JQuery on document ready after load second document

I have web page in which one part is changed dynamically (clock on menu item). I use JQuery in both pages - main - and dynamic and use function on document ready. I cannot use use only in main webpage -because some elements appear only after load internal page. So question is: Will be function onDocumentReady executed only in internal page or in both? Thanks.

Upvotes: 0

Views: 1248

Answers (1)

mu is too short
mu is too short

Reputation: 434665

If you're using an AJAX call to load your new content, then you'll have to use delegate to set up your event bindings or set things up manually in the AJAX success callback; if you need to do something that is more complicated than binding a simple click handler (such as binding a jQuery-UI button or a form validator), then you'll have to do it by hand. For example, if you're using the load convenience function to pull in new content:

$('#mydiv').load('/where/it/comes/from', function(responseText, textStatus, XMLHttpRequest) {
    // Bind events and widgets to the new things inside #mydiv
});

Upvotes: 2

Related Questions