Git Product home page Git Product logo

jquery-once's Introduction

jQuery Once NPM version

Testing NPM downloads Dependency Status Greenkeeper badge

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

Method Installation
npm npm install jquery-once --save
Composer composer require robloach/jquery-once
Bower bower install jquery-once
Component component install RobLoach/jquery-once
jsDelivr //cdn.jsdelivr.net/npm/[email protected]/jquery.once.min.js
cdnjs //cdnjs.cloudflare.com/ajax/libs/jquery-once/2.2.3/jquery.once.js

Usage

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

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

Development

  1. Ensure you are using node >= 4:
node --version
  1. Install dependencies through npm:
npm install
  1. Check coding style standard, and automated testing:
npm test
  1. Build jquery.once.min.js with:
npm run build
  1. Update API documentation:
npm run docs
  1. Tag and publish the new versions to npm with Semantic Versioning:
git add -A
git commit -m "2.1.2"
git tag 2.1.2
git push origin 2.1.2
npm publish

Change Log

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

License

Dual licensed under:

Copyright © Rob Loach

jquery-once's People

Contributors

greenkeeper[bot] avatar johnalbin avatar lukasdrgon avatar olavorn avatar robloach avatar sam152 avatar theodoreb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-once's Issues

An in-range update of uglify-js is breaking the build 🚨

The devDependency uglify-js was updated from 3.6.3 to 3.6.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

uglify-js is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • coverage/coveralls: First build on greenkeeper/uglify-js-3.6.4 at 75.758% (Details).

Release Notes for v3.6.4

 

Commits

The new version differs by 11 commits.

  • 370c8e0 v3.6.4
  • 4240fba fix corner cases in unused (#3519)
  • 267bc70 fix corner case in unused (#3517)
  • a53ab99 fix corner case in side_effects (#3514)
  • 02308a7 fix corner case in reduce_vars (#3510)
  • 0b3705e fix corner cases in inline (#3507)
  • da5a21b fix GitHub Actions script for fuzzing (#3504)
  • 5bd0cf8 enable GitHub Actions (#3503)
  • 9199ab5 minor tweaks (#3502)
  • ca6dce4 fix corner case in collapse_vars (#3501)
  • 543dd7d fix corner case in comments (#3500)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of uglify-js is breaking the build 🚨

The devDependency uglify-js was updated from 3.4.9 to 3.4.10.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

uglify-js is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v3.4.10

 

Commits

The new version differs by 18 commits.

  • 9707ccd v3.4.10
  • cb8f3a2 add Node.js 10 to CI tests (#3342)
  • 8b3259e fix corner case in reduce_vars (#3341)
  • b66f47b update dependencies
  • 8d2e6f3 fix function inlining after reduce_vars (#3340)
  • b3ef5e5 enhance evaluate (#3339)
  • 627f5fb fix corner case with nameCache (#3338)
  • d90777b parse mangle.properties.regex in --config-file properly (#3337)
  • e49297e improve usability of pure_funcs (#3336)
  • ebd82b3 fix corner case in collapse_vars (#3334)
  • d074aa6 fix corner case in collapse_vars (#3333)
  • b052f62 fix corner case in reduce_vars (#3332)
  • d4ac84b fix corner case in arguments & reduce_vars (#3331)
  • e250396 fix corner case in arguments (#3330)
  • c6fa39b Update README.md (#3311)

There are 18 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Check argument type in removeOnce and findOnce

Basically factoring

    id = id || "once";
    if (typeof id !== "string") {
      throw new Error("jQuery.once() parameter must be a string");
    }
    // Build the name for the data identifier. Generate a new unique id if the
    // id parameter is not provided.
    var name = "jquery-once-" + id;

into it's own function and use in once, removeOnce and findOnce

Require ID

Now that $.each is gone from the code, having once called without a parameter looks a lot less godd that it did: $(selector).once().each(). More importantly jquery-once-X is also extremely unhelpful when trying to debug code because there is no way to know where the once is added from in the code.

ID should be required for inspectability purposes and make debugging way easier.

An in-range update of xo is breaking the build 🚨

The devDependency xo was updated from 0.23.0 to 0.24.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

xo is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 13 commits.

  • a64ffc4 0.24.0
  • 71ea1e3 Update dependencies
  • 510d02e CI updates (#360)
  • 7017abe Add no-useless-catch rule
  • 0b411fb Add eslint-plugin-eslint-comments ESLint plugin (#359)
  • 3dd8f7e Update readme to match #305 (#357)
  • dd2c015 Drop support for Babel 6 in the import/no-unassigned-import rule
  • 61f9582 Support parsing ES2019
  • 92f2870 Various code style improvements
  • 9e75826 Add some new eslint-plugin-node rules
  • c7054f3 Update dependencies
  • e656fd4 Mention the badgen.net XO badges in the readme
  • d1fd3e1 Move default ESLint cache to node_modules/.cache/xo. (#351)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of xo is breaking the build 🚨

The devDependency xo was updated from 0.25.4 to 0.26.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

xo is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v0.26.0

Breaking

  • Require Node.js 10 d7fa875
  • Move $ xo --init to $ npm init xo 6463dfe

New rules

20 new rules 👌

ESLint
Unicorn
Other

Enhancements

Fixes

  • Fix compatibility with being run in a child process (#405) 08af7c1

v0.25.3...v0.26.0

Commits

The new version differs by 10 commits ahead by 10, behind by 2.

  • c2bb1bf 0.26.0
  • eb5ea2c Set the es2020 environment by default
  • 08af7c1 Fix compatibility with being run in a child process (#405)
  • d7fa875 Require Node.js 10
  • ab3e01a Temporarily disable the import/order rule
  • c50eaf0 Add some overrides to unicorn/prevent-abbreviations
  • e8c43d2 Replace destructing import with one-by-one import (#417)
  • 5cddaec Replace singular Lodash packages with the main one (#413)
  • 1fdc2f9 Fix Node.js range for prefer-object-spread rule (#408)
  • 6463dfe Move xo --init to npm init xo

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of uglify-js is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 3.3.13 of uglify-js was just published.

Branch Build failing 🚨
Dependency uglify-js
Current Version 3.3.12
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

uglify-js is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v3.3.13

 

Commits

The new version differs by 15 commits.

  • 951d87c v3.3.13
  • 798fc21 improve test/run-test.js performance (#2971)
  • a75a046 compress arguments[index] (#2967)
  • 38f2b45 fix value reference caching in evaluate (#2969)
  • 56e2a36 enhance conditionals (#2966)
  • 0daa199 migrate safe transformations out of unsafe_comps (#2962)
  • 73e98dc drop side_effects-free return values (#2965)
  • 36bca69 enhance collapse_vars (#2952)
  • ace5811 drop lone "use strict" in function body (#2963)
  • ba7bad0 show benchmark subtotal (#2960)
  • b8b2ac5 improve fix for #2954 (#2958)
  • ea23593 fix collapse_vars on nested exception (#2955)
  • 52de64c deduplicate parenthesis around object and function literals (#2953)
  • 4557902 minor clean-ups (#2951)
  • f40f5eb improve mangle (#2948)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/jquery is breaking the build 🚨

Version 3.3.3 of @types/jquery was just published.

Branch Build failing 🚨
Dependency [@types/jquery](https://github.com/DefinitelyTyped/DefinitelyTyped)
Current Version 3.3.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@types/jquery is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of mocha is breaking the build 🚨

Version 5.0.1 of mocha was just published.

Branch Build failing 🚨
Dependency mocha
Current Version 5.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 15 commits.

  • 09ce746 Release v5.0.1
  • 70027b6 update changelog for v5.0.1 [ci skip]
  • 44aae9f add working wallaby config
  • 412cf27 [Update] license year
  • b7377b3 rename help-wanted to "help wanted" in stale.yml
  • d975a6a fix memory leak when run in v8; closes #3119
  • 3509029 update .gitignore to only ignore root mocha.js [ci skip]
  • b57f623 fix: When using --delay, .only() no longer works. Issue #1838
  • cd74322 Slight copy update on docs for test directory
  • f687d2b update docs for the glob
  • 14fc030 Add all supported wallaby editors
  • 2e7e4c0 rename "common-mistake" label to "faq"
  • bca57f4 clarify docs on html, xunit and 3p reporters; closes #1906
  • 2fe2d01 Revert "fix travis "before script" script"
  • c0ac1b9 fix travis "before script" script

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

jQuery(window).once()

It appears that code like this:

jQuery(window).once('fixed-menu').load(function() {
  // Do something
});

will never execute. I'm assuming you can't use once() on window?

Thanks!

An in-range update of xo is breaking the build 🚨

Version 0.22.0 of xo was just published.

Branch Build failing 🚨
Dependency xo
Current Version 0.21.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

xo is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes v0.22.0

Highlights

  • Upgraded to ESLint 5.
  • Removed some patterns from the list of default ignores. They were too opinionated. 00d6b7c 8e4f435
    • fixture{-*,}.{js,jsx}
    • fixture{s,}/**
    • {test,tests,spec,__tests__}/fixture{s,}/**
    • **/bundle.js
  • Added support for TypeScript and documented usage with Flow. 957b0d9
  • Now respects nodeVersion option set in an override block. 98dee9a
  • Fixed the CLI's --space option parsing. f76c901

New rules

All changes

v0.21.1...v0.22.0

Commits

The new version differs by 10 commits.

  • be8c1d1 0.22.0
  • 142744a Bump dependencies
  • 8e4f435 Remove **/bundle.js as default ignore
  • f76c901 Fix CLI's --space option parsing (#342)
  • 98dee9a Respect nodeVersion option set in override block (#345)
  • e783704 Update dependencies and fix unit tests (#344)
  • 404d81b Fix links in documentation (#343)
  • 71d06a0 Upgrade to ESLint 5 (#333)
  • 00d6b7c Don't ignore fixture directories by default (#317)
  • 957b0d9 Add support for TypeScript and document usage with Flow (#326)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add Typescript Suport with @types

Just let create the type definition in the package and point it in packages.json using

//packages.json
{...
types : jquery-once.d.ts
...}

An in-range update of uglify-js is breaking the build 🚨

Version 3.4.9 of uglify-js was just published.

Branch Build failing 🚨
Dependency uglify-js
Current Version 3.4.8
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

uglify-js is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes v3.4.9

 

Commits

The new version differs by 5 commits.

  • ea999b0 v3.4.9
  • ce7e220 fix corner case in conditionals (#3244)
  • 2bdaca1 enhance conditionals (#3243)
  • aa00292 fix corner case in reduce_vars (#3241)
  • f352bce fix corner case in collapse_vars (#3239)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of xo is breaking the build 🚨

The devDependency xo was updated from 0.27.0 to 0.27.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

xo is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v0.27.1
  • Various fixes to TypeScript integration (#431) 0ea5dbb

Important: We changed the cache structure, so you'll need to delete node_modules/.cache/xo:

$ rm node_modules/.cache/xo

v0.27.0...v0.27.1

Commits

The new version differs by 2 commits.

  • ad2a712 0.27.1
  • 0ea5dbb Various fixes to TypeScript integration (#431)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add Documenation

Sorry if this is obvious, but I've tried Googling and I don't know what the parameter is or the significance of it. The README does not say.

For example:

$('div.calendar').once('calendar').each(function() {
  // This function is only executed once for each div, even if this
  // code segment is executed repeatedly.
});

What is 'calendar' here? It doesn't look like a selector. Is it just a name to assign, so I could call it anything? And what is it for? If I use once again on the same selector but with a different parameter will it consider it to be different?

An in-range update of jsdom is breaking the build 🚨

Version 11.12.0 of jsdom was just published.

Branch Build failing 🚨
Dependency jsdom
Current Version 11.11.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

jsdom is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 22 commits.

  • 4d26c67 Version 11.12.0
  • d6688e5 Implement Element.prototype.closest()
  • 9191218 Upgrade NWSAPI to v2.0.7
  • 500a209 Change storageQuota to operate on code units, not bytes
  • 23d67eb Add the storageQuota option
  • b4db242 Remove unused form-data-symbols.js file
  • 70fd739 Fix a few entries in the changelog
  • eae1062 Upgrades cssstyle dependency to ^1.0.0
  • 022c204 Update hosts in Travis configuration
  • 2761d3c HashChangeEvent and PopStateEvent should no longer bubble
  • f1270e7 Roll Web Platform Tests
  • d6f8a97 Enable Blob-slice.html test in Node.js v10
  • 3afbc0f Implement Web storage - localStorage, sessionStorage, StorageEvent
  • 7b4db76 Handle Node.js v6 timeout in execution-timing tests
  • a5a7785 Run failing tests to confirm their status

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.