{"name":"onmount","version":"1.0.0","author":{"name":"Rico Sta. Cruz","email":"rico@ricostacruz.com"},"license":"MIT","_id":"onmount@1.0.0","maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"dist":{"shasum":"0dedf96dac450e2beaafeeb2bed7176cfb7c10f0","tarball":"http://registry-npm.ywwl.com/onmount/download/onmount-1.0.0.tgz","integrity":"sha512-V0pD2C2wBPx1VdmkkQB0ndsHwp6VGekC0uw8jCiYwdHAsr4SjOXVMd4w3NdXPU1yCOgPQbkE4pfViVVH1gLDYw==","signatures":[{"sig":"MEUCIQCtUfvH/TBxQxkAFe/V10sZBqM3KvB7vx233SlzoLRU+gIgOgVuDvhNVqbz0Vvf6N8HAP2TYFEducIvJopx6LGSe9w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":9587,"noattachment":false,"key":"/onmount/-/onmount-1.0.0.tgz"},"main":"index.js","_from":".","_shasum":"0dedf96dac450e2beaafeeb2bed7176cfb7c10f0","gitHead":"5a9b7b98cfe3f803e57771ffb84b020bc8edfefa","scripts":{"test":"mocha"},"_npmUser":{"name":"rstacruz","email":"rico@ricostacruz.com"},"_npmVersion":"2.11.3","description":"Safe, reliable, idempotent and testable behaviors for DOM nodes using jQuery","directories":{},"_nodeVersion":"2.3.1","devDependencies":{"chai":"^3.0.0","jsdom":"^5.4.3","mocha":"^2.2.5","jquery":"^2.1.4","standard":"^4.3.2","mocha-jsdom":"^0.5.0","mocha-standard":"0.0.5"},"readme":"# onmount\n\n<!-- {.massive-header} -->\n\nRun something when a DOM element appears and when it exits.<br>\nNo dependencies. Legacy IE compatible. 1kb .min.gz.\n\n## Overview\n\n### Detecting elements\n\nRun something to initialize an element on its first appearance.\n\n```js\nonmount = require('onmount')\n\nonmount('.push-button', function() {\n  $(this).on('click', function() {\n    alert('working...')\n  })\n})\n```\n\n> _See: [Premise](/docs/premise.md)_\n\n### Using with React\n\n:tada: If you're looking to use Onmount to mount React components, check out [Remount] instead.\n\n### Polling for changes\n\nCall `$.onmount()` everytime your code changes.\n\n```js\n$('<button class=\"push-button\">Do something</button>').appendTo('body')\n\n$.onmount()\n\n$('.push-button').click() //=> 'working...'\n```\n\n> _See: [Idempotency](/docs/idempotency.md)_\n\n### jQuery integration\n\njQuery is optional; use it to poll on popular events.\n\n```js\n$(document).on('ready show.bs closed.bs load page:change', function() {\n  $.onmount()\n})\n```\n\n> _See: [API](/docs/api.md)_\n\n### Cleanups\n\nSupply a 2nd function to _onmount()_ to execute something when the node is first detached.\n\n```js\n$.onmount(\n  '.push-button',\n  function() {\n    /*...*/\n  },\n  function() {\n    alert('button was removed')\n  }\n)\n\ndocument.body.innerHTML = ''\n\n$.onmount() //=> 'button was removed'\n```\n\n> _See: [Cleanups](/docs/cleanup.md)_\n\n## What for?\n\nOnmount is a safe, reliable, idempotent, and testable way to attach JavaScript behaviors to DOM nodes. It's great for common websites that are not Single-Page Apps. Read more on its [premise and motivation](docs/premise.md).\n\n[rsjs][rsjs] (Reasonable System for JavaScript Structure) is a great standard that onmount fits perfectly into.\n\n## Usage\n\nOnmount is available via [npm](https://www.npmjs.com/package/onmount) and Bower.\n\n```\nnpm install onmount\nbower install onmount\n```\n\nIt can be used as a CommonJS module or on its own. It doesn't require jQuery, but if jQuery is found, it'll attach itself to it as `$.onmount`.\n\n```js\nonmount = require('onmount') // With CommonJS (ie, Browserify)\nwindow.onmount // with no module loaders:\n$.onmount // with jQuery\n```\n\n[bootstrap events]: http://getbootstrap.com/javascript/\n[turbolinks load]: https://github.com/rails/turbolinks#events\n[idempotent]: https://en.wiktionary.org/wiki/idempotent\n[browserify]: http://browserify.org/\n\n## API\n\n> _See: [API](docs/api.md)_\n\n## Browser compatibility\n\nAll modern browsers and IE8+. For legacy IE, use it with jQuery 1.x.\n\n## Examples\n\nExamples are available in the source repo. [See examples →](https://github.com/rstacruz/onmount/examples)\n\n## Thanks\n\n**onmount** © 2015+, Rico Sta. Cruz. Released under the [MIT] License.<br>\nAuthored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).\n\n> [ricostacruz.com](http://ricostacruz.com) &nbsp;&middot;&nbsp;\n> GitHub [@rstacruz](https://github.com/rstacruz) &nbsp;&middot;&nbsp;\n> Twitter [@rstacruz](https://twitter.com/rstacruz)\n\n[mit]: http://mit-license.org/\n[contributors]: http://github.com/rstacruz/onmount/contributors\n[rsjs]: https://github.com/rstacruz/rsjs\n\n[![](https://img.shields.io/badge/%E2%9C%93-collaborative_etiquette-brightgreen.svg)](http://git.io/col)\n\n[remount]: https://github.com/rstacruz/remount\n","publish_time":1435665272327,"_cnpm_publish_time":1435665272327,"dist-tags":{"latest":"2.0.0","next":"2.0.0-preview.0"}}