Extends `$().ready()` to provide a convenient syntax for page-specific script
JavaScript
Switch branches/tags
Nothing to show
Latest commit 8aab477 Nov 30, 2015 @ragalie ragalie Merge pull request #4 from manufarfaro/master
#3: Broken link fixed.
Permalink
Failed to load latest commit information.
test Initial commit Sep 11, 2012
.gitignore Initial commit Sep 11, 2012
README.md #3: Broken link fixed. Nov 30, 2015
jquery.readyselector.js Initial commit Sep 11, 2012
package.json Initial commit Sep 11, 2012

README.md

With the Rails asset pipeline or other asset packagers, you usually include the JS for your entire application in one bundle, while individual scripts should be run only on certain pages.

jquery.readyselector extends .ready() to provide a nice syntax for page-specific script:

$('.posts.index').ready(function () {
  // ...
});

This works well if you include the controller name and action as <body> element classes, a la: http://postpostmodern.com/2009/02/20/a-body-with-class/

The callback will be run once for each matching element, with the usual 'this' context for a jQuery callback. $(fn), $(document).ready(fn), and $().ready(fn) behave as normal.