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

jquery-once

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-once

Act on jQuery elements only once.

  • 2.0.0-alpha.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-52.7%
Maintainers
1
Weekly downloads
 
Created
Source

jQuery Once

Build Status NPM version Dependency Status Development Dependency Status
Gittip donate button

Act on jQuery elements only once.

Filters out all elements that had the same filter applied on them before. It can be used to ensure that a function is only applied once to an element.

Install

NPM

  • Use: require('jquery-once')
  • Install: npm install --save jquery-once

Browserify

  • Use: require('jquery-once')
  • Install: npm install --save jquery-once
  • CDN URL: //wzrd.in/bundle/jquery-once@2.0.0-alpha.8

Ender

  • Use: require('jquery-once')
  • Install: ender add jquery-once

Component

  • Use: require('jquery-once')
  • Install: component install RobLoach/jquery-once

Bower

  • Use: require('jquery-once')
  • Install: bower install jquery-once

Usage

.once()

Filter elements by whether they have not yet been processed.

$('div.calendar').once('calendar').each(function() {
  // This function is only executed once for each div, even if this
  // code segment is executed repeatedly.
});
$('div.calendar').once('calendar').click(function() {
  // .once('calendar') filters out all elements which already have been
  // filtered with once(), and the elements that haven't been filtered
  // yet remain. The previous set of elements can be restored with
  // .end().
});

It is also possible to use .once() without supplying a name:

$('div.calendar').once().each(function() {
  // This function is only executed once for each div, even if this
  // code segment is executed repeatedly. Other scripts can't refer
  // to this `once` method. The once data used to store execution are
  // in the form "jquery-once-1", "jquery-once-2", etc.
});

.findOnce()

After .once() is used and you need to retrieve all elements that have already been executed with .once(), you can use the `.findOnce() function:

$('div.calendar').findOnce('calendar').each(function() {
  // This function is called for each element that was already called "once"
  // with the "calendar" ID.
});

.removeOnce()

It is possible to remove the .once() data, and iterate through each element whose once state is removed:

$('div.calendar').removeOnce('calendar').each(function() {
  // This function is called for each element whose once() data is removed.
});

Development

Install dependencies through npm:

npm install

Use Grunt to run qunit tests:

grunt jshint qunit

Build the project with Grunt:

grunt release

Update project documentation with Projectz:

npm run-script projectz

Generate code documentation with JSDoc:

npm run-script jsdoc

History

Discover the change history by heading on over to the HISTORY.md file.

License

Licensed under:

Copyright © Rob Loach (http://github.com/RobLoach)

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gittip donate button

Contributors

These amazing people have contributed code to this project:

Become a contributor!

Keywords

FAQs

Package last updated on 09 Oct 2014

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