{"name":"onmount","version":"1.2.0","keywords":["dom","enter","exit","mutation","mutationobserver","observe"],"author":{"name":"Rico Sta. Cruz","email":"rico@ricostacruz.com"},"license":"MIT","_id":"onmount@1.2.0","maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"homepage":"https://github.com/rstacruz/onmount#readme","bugs":{"url":"https://github.com/rstacruz/onmount/issues"},"dist":{"shasum":"991f3f29bda85cb4492ccde961c5c96be46fe2a1","tarball":"http://registry-npm.ywwl.com/onmount/download/onmount-1.2.0.tgz","integrity":"sha512-VCZIykyzpnEeG7sOv6NgUyhiXeHsiYzqhjpe1JNpi/CfSoIlURubi6QhfsqXlzPQbvhk56N5EKGSywDgGgRfnA==","signatures":[{"sig":"MEQCIGyZ6Zf6B4IpoEkygr+eMlo1jAb0OQZR5GhnXdjXuGrMAiAYNmJX5YXVYPZXgmgagBm20hijLjK9gze8iam/ndmFJg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":14042,"noattachment":false,"key":"/onmount/-/onmount-1.2.0.tgz"},"main":"index.js","_from":".","_shasum":"991f3f29bda85cb4492ccde961c5c96be46fe2a1","gitHead":"2ba5813b18556020924ea3c8b9b5bf368cd24b8e","scripts":{"test":"node test"},"_npmUser":{"name":"rstacruz","email":"dropbox@ricostacruz.com"},"repository":{"url":"git+https://github.com/rstacruz/onmount.git","type":"git"},"_npmVersion":"2.14.12","description":"Run something when a DOM element appears and when it exits","directories":{"doc":"docs","test":"test","example":"examples"},"_nodeVersion":"4.3.0","devDependencies":{"tape":"4.4.0","jsdom":"8.1.0","eslint":"1.10.3","jquery":"2.2.0","docpress":"0.6.10","tape-around":"2.2.0","tape-eslint":"1.2.1","jsdom-global":"1.6.1","git-update-ghpages":"1.3.0","eslint-config-standard":"4.4.0","eslint-plugin-standard":"1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/onmount-1.2.0.tgz_1458055687223_0.827270103385672","host":"packages-13-west.internal.npmjs.com"},"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":1458055687779,"_cnpm_publish_time":1458055687779,"dist-tags":{"latest":"2.0.0","next":"2.0.0-preview.0"}}