Yes - its a legacy thing this. IE6 didn't support unshift, so when DataTables, internally, needed to put something at the start of the callback arrays (mainly the draw callback) I put the element at the end of the array and reverse looped over it. In retrospect that was probably wrong, I should have used splice...
Slightly concerned that changing it to be a forward loop might break things, which is why that baggage is still with us. I might look at altering it when I update the DataTables events system (which really needs a bit of a clean out - but that will be after 1.10 I think now).
Thanks, nice to hear that you already had plan to alter this confusing behavior in the future release.
Before I just supposed that the callbacks should be fired/triggered in the order they are registered, but once I found the behavior was different to my assumption, so I dive into the source code and found this. For now, I have to be very careful about the time point to register a callback which may depend on other registered ones. Or I just reminded myself that the callbacks registered have to be independent to avoid the potential problem...
These days I am looking at jQuery.Callbacks (http://api.jquery.com/category/callbacks-object/) and jQuery.Deferred (http://api.jquery.com/category/deferred-object/) . Do you ever consider to make use of the APIs to enhance the callbacks in DataTables?
Possibly yes. DataTables has needed compatibility with 1.4+ previously, but I might increase that to even 1.7 with 1.10 release - not yet sure. I'll certainly be looking into it.
Replies
Slightly concerned that changing it to be a forward loop might break things, which is why that baggage is still with us. I might look at altering it when I update the DataTables events system (which really needs a bit of a clean out - but that will be after 1.10 I think now).
Regards,
Allan
Before I just supposed that the callbacks should be fired/triggered in the order they are registered, but once I found the behavior was different to my assumption, so I dive into the source code and found this. For now, I have to be very careful about the time point to register a callback which may depend on other registered ones. Or I just reminded myself that the callbacks registered have to be independent to avoid the potential problem...
Regards,
Roy
These days I am looking at jQuery.Callbacks (http://api.jquery.com/category/callbacks-object/) and jQuery.Deferred (http://api.jquery.com/category/deferred-object/) . Do you ever consider to make use of the APIs to enhance the callbacks in DataTables?
Regards,
Roy
Allan