Created
April 21, 2014 11:48
-
-
Save storytime/11140471 to your computer and use it in GitHub Desktop.
RequireJS Example
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
define(function () { | |
return function (s) { | |
return s.toUpperCase(); | |
}; | |
}); |
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> | |
<title>My Sample Project</title> | |
<!-- data-main attribute tells require.scripts to load | |
scripts/main.scripts after require.scripts loads. --> | |
<script data-main="scripts/main" src="http://requirejs.org/docs/release/2.1.11/comments/require.js"></script> | |
</head> | |
<body> | |
<h1>My Sample Project</h1> | |
</body> | |
</html> |
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
require(["helper/fk", "helper/values"], function (fk,val) { | |
//This function is called when scripts/helper/values.js is loaded. | |
//If values.js calls define(), then this function is not fired until | |
//util's dependencies have loaded, and the util argument will hold | |
//the module value for "helper/util". | |
console.log("from values.js " + val.red) | |
console.log("from fk.ks " + fk("string")) | |
}); |
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
define ( | |
{ | |
red: "red", | |
green: "green", | |
black: "black" | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment