Skip to content

Instantly share code, notes, and snippets.

@philmander
Last active December 10, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philmander/4424805 to your computer and use it in GitHub Desktop.
Save philmander/4424805 to your computer and use it in GitHub Desktop.
//example app config defining a jquery proto
define({function() {
return: {
protos: {
jquery: {
//assuming jquery's url is
//defined in the amd paths config
module: "jquery",
scope: "static"
},
movieThing: {
module: "movies/movie-thing",
props: {
setJquery: "*jquery"
}
}
}
}
};
//injecting jquery with Inverted
define(function() {
//store jquery ref in closure
var $;
var MovieThing = function() {
}
MovieThing.prototype.doStuff = function() {
$("#hello").append("Hello");
};
MovieThing.prototype.setJquery = function(jQuery) {
$ = jQuery;
};
return MovieThing;
});
//loading jquery normally with an AMD loader
define(["jquery"], function($) {
var MovieThing = function() {
}
MovieThing.prototype.doStuff = function() {
$("#hello").append("Hello");
};
return MovieThing;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment