Skip to content

Instantly share code, notes, and snippets.

@djs070
Forked from mxriverlynn/1.js
Created November 15, 2012 07:04
Show Gist options
  • Save djs070/4077158 to your computer and use it in GitHub Desktop.
Save djs070/4077158 to your computer and use it in GitHub Desktop.
$(function(){...}) vs (function($){...})($)
(function($) {
// Backbone code in here
})(jQuery);
$(function(){
// Backbone code in here
});
// Define "MyApp" as a revealing module
MyApp = (function(Backbone, $){
var View = Backbone.View.extend({
// do stuff here
});
return {
init: function(){
var view = new View();
$("#some-div").html(view.render().el);
}
};
})(Backbone, jQuery);
// Run "MyApp" in DOMReady
$(function(){
MyApp.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment