paulirish/infinite-scroll — pull request #459 by bronson (2013-09-20 02:10:42+00:00)
Title: add option to send ajax data straight to the callback

I have a callback that receives html data, then inserts it in the correct place in the DOM. Unfortunately, Infinite Scroll corrupts the data before the callback can be called.

This option prevents that.

This actually isn't meant for upstream inclusion because eew, but I hope it starts discussion or illustrates where I'm going horribly wrong.

Here's the way I use it:

```javascript
//
// infinite scroll
//
$("#assets").infinitescroll(
{
loading: {
msgText: "Loading more listings...",
finishedMsg: "No more listings."
},
navSelector: "nav.pagination",
nextSelector: "nav.pagination a[rel=next]",
appendCallback: false,
dontScrewUpTheData: true,
path: function (page) {
var query = window.location.search.replace(/([?;&])page=[0-9]+[?;&]/, "$1") // remove ?page= from querystring
return "/results" + (query.length > 2 ? query + "&" : "?") + "page=" + page
},
},
function (data,opts,url) {
if(data.trim() != "") {
compute_destination().append(data)
} else {
return "end"
}
}
)
// unfortunately infinitescroll doesn't hide the paginators until AFTER it starts
// ajaxing the new content so the paginators appear & flash off quickly. Ugly.
// Quick workaround that obviously won't get in the way if javascript is turned off:
$('nav.pagination').hide()
```

I'm very open to comments on how I can do this better. Just muddling along the best I can...