The question is that there are some functions that I call to initial some elements on the page. But after ajax success, I have to re-call those functions again and again in multiple places. I was wondering beside using the following combo
$(document).ready(function(){
function A
});
$(document).ajaxComplete(function(){
function A
});
I read that there are something I can do with the setTimeout and clock up the thread to delay the function call from the link http://googlecode.blogspot.com/2009/07/gmail-for-mobile-html5-series-using.html but I have a hard time digesting it. If someone can break it down for me.
Update:
I meant that when I do an html updated inside multiple ajax success, I have to call function A to re initialize and the code above is my idea but I think there should be a better way
Example
$(document).on('click', 'a', function() {
$.ajax({
type: 'GET',
url: 'some url',
data: data,
success: function(data) {
$('#some-sector').html(data);
function A; <------- to init
}
});
});
$(document).on('click', 'b', function() {
$.ajax({
type: 'GET',
url: 'another url',
data: data,
success: function(data) {
$('#some-sector').html(data);
function A; <------- to init
}
});
});
Another Update:
So Basically there are some elements on the page that I need to update dynamically by calling function A. And from the example, I have multiple ajax that updates a page. Instead of calling function A in multiple the ajax success, I was wondering if there is a better way to do this. The only thing that i could think of it's the top code.