Comments (3)
I wrote some code to do this yesterday. It's not in the initial plugin. You'll need to delete the call to AjaxLoadMore.loadPosts() and then change the click/scroll functions to increment the pages after calling AjaxLoadMore.loadPosts().
In my version I've added an autoload/preload variable and made this optional
from ajax-load-more.
Add a new variable at the top:
var autoLoad = false;
add this before the the load more method AjaxLoadMore.loadPosts:
if (autoLoad === true) {
$('#load-more').text("Loading...");
} else if (autoLoad === false) {
$loading = false;
}
Then change your click and scroll handlers to this and add a conditional to increment the pages if you do decide to turn autoload on (can skip that if statement if you're never going to turn autoload on)
$button.click(function (e) {
e.preventDefault();
if (!$loading && !$finished && !$(this).hasClass('done')) {
$loading = true;
AjaxLoadMore.loadPosts();
page++;
}
});
if ($scroll) {
$window.scroll(function () {
var content_offset = $button.offset();
if (!$loading && !$finished && $window.scrollTop() >= Math.round(content_offset.top - ($window.height() - 150)) && page < $max_pages) {
$loading = true;
AjaxLoadMore.loadPosts();
page++;
}
});
}
if (autoLoad === true) {
AjaxLoadMore.loadPosts();
page++;
}
from ajax-load-more.
Yes, the JS file. I'm sorry I don't have time to make the changes for you, it took enough time to extract that from my own code.
Have a nice day.
from ajax-load-more.
Related Issues (20)
- IE 11 script error HOT 2
- Not working with LiteSpeed Cache plugin JS minify option HOT 1
- Can this be used without wordpress?
- pace.min.js is corrupting XMLHttpRequest.DONE value HOT 3
- FEATURE REQUEST: Add more dynamics/options for toc element
- Is there a way to fire/trigger the load more button dynamically?
- Suggestions for ALM
- scroll="false" doesnt work for the first time... HOT 2
- Get current page slug raises an issue if alm instance is in the author page's context HOT 5
- Ajax load more : Next page add-on admin settings HOT 3
- html: false on first page HOT 2
- pre_get_posts - is_admin() returning true when loaded from public page HOT 2
- 414 Entity-Too-Large errors
- internal penetration test flagged for xs HOT 2
- Security concern HOT 2
- Feature Request: Optional preloaded wrapper HOT 1
- Umlauts not working
- This plugin doesn't support to filter results by custom query. This is a big problem. HOT 4
- Unused CSS HOT 1
- Shortcode Functionality When Using '<' Character HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajax-load-more.