Last active
June 25, 2017 10:17
-
-
Save stopanko/8f2fda58ec0b88a60e089e5a5fc2ebe3 to your computer and use it in GitHub Desktop.
how make script loaded only on specific page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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