Tags: #js
define(function() {
return function Person(fullname) {
this.name = fullname;
}
});
<!doctype html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8">
<title>Curl (Cujo Resource Loader)</title>
</head>
<body>
<script type="text/javascript">
curl = {
baseUrl: 'Assets/Scripts',
paths: {
curl: 'Curl',
jquery: 'Utils/jquery'
}
};
</script>
<script src="Assets/Scripts/Curl.js"></script>
<script type="text/javascript">
curl(['App/people'], function(o) {
console.log(o.list, o.scripts);
});
</script>
</body>
</html>
define(['Models/Person', 'Utils/random', 'jquery'], function (Person, randomUtility, $) {
var people = [],
scriptsOnPage = $('script');
people.push(new Person('Jim'));
people.push(new Person(randomUtility.someValue));
return { list: people, scripts: scriptsOnPage };
});
define(function() {
function method (x) {
return x + x;
}
return {
someValue: 'foobar',
myMethod: method
}
});