mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-19 12:52:11 +01:00
New - experimental: Add custom events into DataTables - the events available are "draw", "filter", "sort", "page" and "xhr". These are very useful for knowing when these actions happen and binding an action to them. Useful for plugin developers and developers using DataTables both. Note that it would be possible to put in a _LOT_ more custom events ("predraw" etc) which is why this feature is currently considered experimental. It will not be documented in the DataTables documentation until this has stabilised (likely 1.9 or 2.0) and a scheme has been fully confirmed for these events, but I want to include them now to see if and how they are used by developers to see them or talk to me (as this has been asked for a few times). I'm also slightly concerned about the overhead that would be generated if there were custom events for everything.
This commit is contained in:
parent
31ccd959bc
commit
8a8ca1e7b8
9
media/js/jquery.dataTables.js
vendored
9
media/js/jquery.dataTables.js
vendored
@ -1337,7 +1337,10 @@
|
||||
settings.jqXHR = $.ajax( {
|
||||
"url": url,
|
||||
"data": data,
|
||||
"success": callback,
|
||||
"success": function (json) {
|
||||
$(settings.oInstance).trigger('xhr', json);
|
||||
callback( json );
|
||||
},
|
||||
"dataType": "json",
|
||||
"cache": false,
|
||||
"error": function (xhr, error, thrown) {
|
||||
@ -3388,6 +3391,7 @@
|
||||
{
|
||||
oSettings.aoDrawCallback[i].fn.call( oSettings.oInstance, oSettings );
|
||||
}
|
||||
$(oSettings.oInstance).trigger('draw');
|
||||
|
||||
/* Draw is complete, sorting and filtering must be as well */
|
||||
oSettings.bSorted = false;
|
||||
@ -4345,6 +4349,7 @@
|
||||
|
||||
/* Tell the draw function we have been filtering */
|
||||
oSettings.bFiltered = true;
|
||||
$(oSettings.oInstance).trigger('filter');
|
||||
|
||||
/* Redraw the table */
|
||||
oSettings._iDisplayStart = 0;
|
||||
@ -4730,6 +4735,7 @@
|
||||
|
||||
/* Tell the draw function that we have sorted the data */
|
||||
oSettings.bSorted = true;
|
||||
$(oSettings.oInstance).trigger('sort');
|
||||
|
||||
/* Copy the master data into the draw array and re-draw */
|
||||
if ( oSettings.oFeatures.bFilter )
|
||||
@ -5123,6 +5129,7 @@
|
||||
{
|
||||
_fnLog( oSettings, 0, "Unknown paging action: "+sAction );
|
||||
}
|
||||
$(oSettings.oInstance).trigger('page');
|
||||
|
||||
return iOldStart != oSettings._iDisplayStart;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user