JSPM

  • Created
  • Published
  • Downloads 4529
  • Score
    100M100P100Q125821F

Act on jQuery elements only once.

Package Exports

  • jquery-once

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jquery-once) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.9

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().
});

.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!