JSPM

  • Created
  • Published
  • Downloads 3653
  • Score
    100M100P100Q121942F

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 NPM downloads Dependency Status Dev Dependency Status

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

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

// The following will change the color of each paragraph to red, just once
// for the "changecolor" key.
$('p').once('changecolor').css('color', 'red');

// .once() will return a set of elements that yet to have the once ID
// associated with them. You can return to the original collection set by
// using .end().
$('p')
  .once("changecolorblue")
    .css("color", "blue")
  .end()
  .css("color", "red");

// To execute a function on the once set, you can use jQuery's each().
$('div.calendar').once().each(function() {
  // Since there is no once ID provided here, the key will be "once".
});

See the API documentation for more information on how to use jQuery Once.

Development

Install dependencies through npm:

npm install

Test with ESLint, Mocha and Mocha JSDom:

npm test

Build jquery.once.min.js with:

npm run build

Update API documentation with jsdoc-to-markdown:

npm run docs

Tag and publish the new versions to npm with Semantic Versioning:

git tag 2.0.0
git push origin 2.0.0
npm publish

History

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

License

Licensed under:

Copyright © Rob Loach