Skip to content

Instantly share code, notes, and snippets.

@yeukhon
Created September 6, 2013 04:30
Show Gist options
  • Select an option

  • Save yeukhon/6459578 to your computer and use it in GitHub Desktop.

Select an option

Save yeukhon/6459578 to your computer and use it in GitHub Desktop.
/*
* This app depends on jquery and a remote script called "remote.js" (serve over localhost :p)
* Locally I will have main.js and require.js.
* main.js contain an entry function "init" and it depends on jquery
* and remote.js to be fully loaded.
*/
require.config({
paths: {
"jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min",
"remote": "http://localhost:8000/scripts/remote"
},
shim: {
"init": {
deps: ["jquery", "remote"]
}
},
urlArgs: "bust=" + (new Date()).getTime()
});
//define("init", ["jquery", "remote"], function($, remote) {
define(["jquery", "remote"], function($, remote) {
console.log("just entered the outerscope of the init function.");
console.log(remote);
remote.remoteF1();
});
define(["jquery"], function($) {
return {
color: "blue",
size: "large",
remoteF1: function() {
console.log("remoteF1 is called.");
$('h1').text(this.color);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment