-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this work with AJAX and asynchronous calls #29
Comments
Hi mate I got this working with AJAX using content and callback (though callback worked better): callback: function(fireSequence, pageSequence, scrollDirection) |
I think this works fine in the callback - but is there a way to delay further calls until the success of the ajax? Like a way to stop more firing until the ajax function says it is ok to process more? |
I'm having the same problem :-( |
Hi, This can be done using " fireOnce:true" If fireOnce :true // only fire once until the execution of the current event is completed Example : |
I guess then you should update in the success function so that the property will fire again. |
As far as I understand, the But even with if (!_this.shouldTryFiring()) { return; } if (_this.ceaseFireWhenNecessary()) { return; } if (!_this.shouldBeFiring()) { return; } _this.resetFireSequenceWhenNecessary(); _this.acknowledgeFiring(); _this.insertLoader(); if (_this.hasContent()) { _this.showContent(); _this.fireCallback(); _this.cleanUpPagesWhenNecessary(); _this.delayFiringWhenNecessary(); } _this.removeLoader(); return _this.lastContent = _this.content;
The only solution would be to be to "block" the return value of the I'm trying to find a workaround using |
I think I found a reliable way do this with few changes
// Keeps trace of AJAX loading state var loading = false; // Disable insertLoader / removeLoader EndlessScroll.prototype.insertLoader = function() {}; EndlessScroll.prototype.removeLoader = function() {}; // Redefine shouldBeFiring to be aware of AJAX loading EndlessScroll.prototype.shouldBeFiring = function() { this.calculateScrollableCanvas(); return this.isScrollable && (this.options.fireOnce === false || (this.options.fireOnce === true && this.fired !== true && !loading)); }; $('#element').endlessScroll({ fireOnce: true, loader: '', ceaseFireOnEmpty: false, callback: function(i, p, d) { // Enable loading state loading = true; $('.scroll-loader').append('<a class="ajax-loader"></a>'); $.ajax({ type: "GET", url: "ajax.php", data: "p=" + p +1, success: function(html) { // Disable loading state loading = false; $('.scroll-loader a').fadeOut(function() { return $(this).remove(); }); } }); } }); |
](url) |
I've looked at the source to understand the API better, but it looks like, since it expects a string to be returned from the callback synchronously that it isn't possible to use this with an ajax callback, is this correct?
The text was updated successfully, but these errors were encountered: