I would like all AJAX loaded content in my app to be evaluated by my application JQuery script, the same as normal loaded content is. e.g. JQuery scans through the AJAX loaded content for selectors, like ‘modal box links’ etc.
All my JavaScript is in the normal document.ready, which works fine for normal HTTP loaded pages:
$(document).ready(function(){
// my apps javascript
});
I would like to use something like .ajaxComplete to fire a re-run of everything contained in document.ready to evaluate newly loaded AJAX content for jquery selectors.
$(document).ajaxComplete(function(){
// Re-run all my apps javascript
})
Is there some code I can put in .ajaxComplete to do this?
Hope this makes sense, please let me know if it doesn’t, and I will edit question details.
you could encapsulate everything in your
document.readyinto a function and just call that function again to re-bindor…
a better approach would be to take advantage of the
live()anddelegate()jQuery methods so that all current and future elements matching those selectors will be bound to these events as well.example using
live(): http://api.jquery.com/live/example using
delegate(): http://api.jquery.com/delegate/