Skip to content

Instantly share code, notes, and snippets.

@stopanko
Last active June 25, 2017 10:17
Show Gist options
  • Save stopanko/8f2fda58ec0b88a60e089e5a5fc2ebe3 to your computer and use it in GitHub Desktop.
Save stopanko/8f2fda58ec0b88a60e089e5a5fc2ebe3 to your computer and use it in GitHub Desktop.
how make script loaded only on specific page
# Selector ready function for jQuery 3+
```javascript
(function ($) {
$.fn.selectorReady = function(fn) {
$($.proxy(function() {
$(this).each(fn);
}, this));
};
})(jQuery);
```
|-app/
|---assets/
|-----images/
|-----javascripts/
|-----stylesheets/
**Usage:**
---
<body class=" controller_name action_name">
</body>
$('.controller_name.action_name').selectorReady(function(){
alert('.controller_name.action_name Page')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment