Created
July 5, 2011 06:46
-
-
Save skippy/1064363 to your computer and use it in GitHub Desktop.
require within own namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.myApp = window.myApp || {}; | |
(function( myApp, undefined ) { | |
var require, define; | |
(function () { | |
//wrap require.js in our namespace! | |
var version = "0.24.0"......... | |
}()); | |
myApp.require = require; | |
myApp.define = define; | |
}( window.myApp )); | |
(function( myApp, undefined ) { | |
var setupOptions = {}; | |
var coreLibraries = []; | |
myApp.require(["vendor/jquery.1.6.2"], function($) { | |
// right here, '$' is null (not undefined) | |
}); | |
}( window.myApp )); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://requirejs.org/docs/release/0.24.0/minified/require.js"></script> | |
<script> | |
require(["javascripts/vendor/jquery.1.6.2"], function($) { | |
// $ == null; how odd! | |
console.log("TEST: ", $) | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>test</h1> | |
<p>Look at source or inspect the DOM to see how it works.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment