Hi, This is one of my more 'complicated' methods that just seem like using .bind(this) at the end of the inner functions would make the code read more confusing.. I believe I have some other methods somewhere that actually pass functions as params inside those beforeCreate, afterFinish blocks, and they too would require .bind -- and at the point it just gets really ugly...
autoUpdate: function(was_in_progress) {
var frequency = $F('page_updater_frequency');
var admin_table = this;
if (!this.periodical_executer.updater) {
admin_table.periodical_executer.updater = new
PeriodicalExecuter(function() {
if
(!admin_table.periodical_executer.request_in_progress) {
admin_table.params =
{'authenticity_token':
Utilities.getAuthToken(),
'was_in_progress': was_in_progress};
new Ajax.Request(_location(), {
method: 'get',
parameters:
admin_table.getParams(),
onCreate: function() {
admin_table.periodical_executer.request_in_progress = true;
},
onComplete: function(r)
{
admin_table.periodical_executer.request_in_progress = false;
var json =
Utilities.updateElements(r);
if
(json.js_data && json.js_data.should_stop) {
admin_table.periodical_executer.updater.stop();
var
effected = admin_table.periodical_executer.glowing;
if
(effected) {
// stop glowing effect
effected.stopGlow();
}
admin_table.periodical_executer = {};
}
else {
//
typewriter effect for updated info
var
for_typewriter = json.partials.select(function(e)
{ return admin_table.type_writer_ids.include(e.id); });
for_typewriter.each(function(e) {
_typeWriter(e.id);
})
}
}
});
}
}, frequency);
}
else {
alert('There is a request currently in
progress. Please try again
later or refresh the page.');
return false;
}
}
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.
