I don't think you can go without an onComplete
handler, unless you want to rewrite the prototype ajax API. However you do not have to directly pass a closure to the onComplete
handler.
What you could do is create an empty object on top level scope within your javascript code:
var updates = { } ;
Now you would set the onComplete
parameter to contain a compact function that sets a property to the updates
object by the name of the div you updated (+ date for multiple updates):
function update() {
var divName = arguments[0] ;
var date = new Date() ;
if( updates[divName] ) { //!! if there is an entry for that div fill date
updates[divName].push(date) ;
} else { //!! else create a new array with the current date
updates[divName] = [ date ] ;
}
}
Now you may check for updates by checking the object for a property by the name of the div:
/* code */
if( updates[divName] !== null ) {
isAlreadyUpdated() ;
} else {
isNotAlreadyUpdated() ;
}
/* more code */
Btw, I'm not excluding the possibility that there may be a method in the prototype API that will do something similar. I'm not that familiar with prototype.
If there is none however, I hope this will help!
FK