Skip to content

Instantly share code, notes, and snippets.

@patrickheeney
Last active August 29, 2015 13:57
Show Gist options
  • Save patrickheeney/9536389 to your computer and use it in GitHub Desktop.
Save patrickheeney/9536389 to your computer and use it in GitHub Desktop.
/*APP.core = {
fire: function( controller, page_action ) {
var action = ( !page_action || page_action === "" ) ? "init" : page_action;
//window.console.log(controller);
//window.console.log(page_action);
//window.console.log(action);
if ( controller !== "" && APP[controller] && typeof APP[controller][action] == "function" ) {
APP[controller][action]();
}
},
init: function() {
var $body = $(document.body),
controller = $body.data( "data-controller" ),
action = $body.data( "data-action" );
APP.core.fire( "global" );
APP.core.fire( controller, action );
APP.core.fire( "global", "finalize" );
}
};*/
// Versus
APP.core = function() {
var $body = $(document.body);
var fire = function( controller, page_action ) {
var action = ( !page_action || page_action === "" ) ? "init" : page_action;
//window.console.log(controller);
//window.console.log(page_action);
//window.console.log(action);
if ( controller !== "" && APP[controller] && typeof APP[controller][action] == "function" ) {
APP[controller][action]();
}
};
var init = function() {
var controller = $body.data( "data-controller" ),
action = $body.data( "data-action" );
window.console.log('test');
fire( "global" );
fire( controller, action );
fire( "global", "finalize" );
};
return {
init: init
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment