shtalinberg/django-el-pagination

The 'fragment' of 'onCompleted' callback is not a live set of Nodes

Opened this issue · 0 comments

The onCompleted callback for AJAX'ed pagination uses two parameters: context and fragment, the former being an object containing information about the requested page while the latter is a mere String (data as returned by the server).

While this fragment can have its uses, it will be much more useful if the callback function would be passed the actual DOM (or jQuery) object already inserted into the page. Specifically, in a backwards-compatible manner:

  function(context, fragmentString, fragmentObject) { ... }

with fragmentObject being basically the result of $(fragment).
(It cannot obviously be done in the callback function itself, because this operation will create a new set of DOM nodes, rather than referring to the set already inserted into the DOM tree by the el_pagination script.)

[For context, my own use case requires running an operation on the newly-added nodes and only on them, not on the nodes already existing on the page...]