Skip to content
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

Implementation of a 'reload' method (extremely useful to rebind an updated DOM) #153

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/jquery-ias.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,33 @@
return this;
};

/**
* Reload IAS
*
* Note: Useful when the items container DOM is modified by external actions
*
* @public
*/
IAS.prototype.reload = function() {
// IMPORTANT: Redefine items container to get correct item in getLastItem method
this.$itemsContainer = $(this.itemsContainerSelector);

var currentScrollOffset = this.getCurrentScrollOffset(this.$scrollContainer),
scrollThreshold = this.getScrollThreshold();

this.hidePagination();
this.bind();

this.nextUrl = this.getNextUrl();

// start loading next page if content is shorter than page fold
if (currentScrollOffset >= scrollThreshold) {
this.next();
}

return this;
};

/**
* Binds IAS to DOM events
*
Expand Down