Skip to content

Instantly share code, notes, and snippets.

@mandelbro
Last active December 23, 2015 11:09
Show Gist options
  • Save mandelbro/6626234 to your computer and use it in GitHub Desktop.
Save mandelbro/6626234 to your computer and use it in GitHub Desktop.
/**
* Blueprint JS starter view controller
*/
var exampleViewController = (function( $, window, undefined ) {
// this is a private function
var buildListeners = function() {
var self = this,
// add a map of callbacks to use for the listeners below
callbacks = {};
// this.elements.main.on('click', callbacks.gridItemClicked);
};
var buildTemplates = function() {
// add to the templates object, these are accessible through the this.theme method
this.templates = {};
};
// Add more helper functions as needed
return {
// this is the entry point of your view controller
'construct' : function() {
// take a look at the methods and properties available to you
console.log(this);
// run private functions with apply to use 'this'
buildListeners.apply(this);
buildTemplates.apply(this);
}
};
})( window.Zepto || window.jQuery, this,);
;(function( $, window, undefined ) {
// call the function on ready for all elements
$(window).on('load', function() {
$('.elements').each(function() {
// init blueprint on this viewController
Blueprint(exampleViewController, $(this));
});
});
})( window.Zepto || window.jQuery, this );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment