Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ko-infinitescroll

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ko-infinitescroll

KnockoutJS Infinite Scroll Binding

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
49
increased by25.64%
Maintainers
1
Weekly downloads
 
Created
Source

ko-infinitescroll

KnockoutJS binding to handle infinite scrolling.

Usage

// in real life this would be a prop on your viewModel
var todos = ko.observableArray([])

function fetchTodos() {
  // `this` is the binding context
  var ctx = this

  ctx._page = ctx._page ? ++ctx._page : 1

  // Return promise so infinite scroll function can be disabled
  // until the call is resolved. If no promise is returned the
  // infinite scroll function is assumed to be synchronous
	return $.get('/todos', { page: ctx._page }, function(newTodos) {

    // append new todos
		todos.push.apply(todos, newTodos)
	})
}

// Load initial todos
fetchTodos()
<div data-bind="foreach: todos, infiniteScroll: fetchToDos">
  <div data-bind="template: { name: 'todo-template', data: $data }"></div>
</div>

or

<div data-bind="foreach: todos, infiniteScroll: { handler: fetchToDos, offset: 2000 }">
  <div data-bind="template: { name: 'todo-template', data: $data }"></div>
</div>

In this second snippet, we specify a different offset (in px). Defaults to 1500px.

Depends on Knockout, jQuery, and Lodash
But you're using these already, right?

Keywords

FAQs

Package last updated on 02 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc