Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
jQuery selector scoping technique using currying
<body class="<%= "#{params[:controller]} #{params[:action]}" %>">
// lib/jquery_extensions.js
var setSelectorContext = function(container) {
return function(query) {
return $(container).find(query)
// app/assets/javascripts/user.js
$(function() {
var $$$ = setSelectorContext('.users.index')
$$$('.profile') == $('.users.index .profile') // returns true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment