Skip to content

Instantly share code, notes, and snippets.

@foleyatwork
Last active September 8, 2015 17:09
Show Gist options
  • Save foleyatwork/6bbc1ff52a6dddbd7624 to your computer and use it in GitHub Desktop.
Save foleyatwork/6bbc1ff52a6dddbd7624 to your computer and use it in GitHub Desktop.
An example of a controller.
/**
* This controller pattern relies on a createController method that
* I typically create in my site.js. To see a boilerplate site.js file
* that works with this style, see the link below.
*
* @see https://gist.github.com/foleyatwork/f2a67d4a28f43a55d1cd
*/
Site.createController('RefreshImagesOnResize', function() {
// When using jQuery inside of a controller, just assume the
// '$' global is available.
$(window).resize(function() {
$('img[data-src]').each(function() {
ImageLoader.load(this);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment