Skip to content

Instantly share code, notes, and snippets.

@robertsosinski
Created March 28, 2011 04:28
Show Gist options
  • Select an option

  • Save robertsosinski/890005 to your computer and use it in GitHub Desktop.

Select an option

Save robertsosinski/890005 to your computer and use it in GitHub Desktop.
Specify controller and action for jQuery load event.
!!!
%html
%head
%body{:class => params[:controller], :id => params[:action]}
= yield
(function($) {
$.start('lists#index', function() {
console.log('lists controller - index action');
});
})(jQuery);
(function($) {
$.start = function(selector, callback) {
var output = $(function() {
if ($('body.'+selector).length) {
callback();
}
});
return output;
};
})(jQuery);
(function($) {
$.start('lists', function() {
console.log('lists controller');
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment