Created
July 19, 2011 15:35
-
-
Save BruceHubbard/1092805 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( | |
// template dependency | |
[ | |
'app/text!app/views/templates/myMustacheTemplate.html', | |
'Scripts/mustache/mustache', | |
'Scripts/jquery', | |
'Scripts/jquery-ui-1.8.13.min', | |
'app/services/myServiceFile' | |
], | |
/* This runs once dependencies are loaded */ | |
function (myTpl) { | |
//you can now use jquery, jqueryUI, mustache, myService (app level service js file) and | |
// the myTpl variable will contain the text contents of myMustacheTemplate.html so you run | |
// run mustache on it | |
//This means all of your dependencies are declared here locally instead of outside the scope of | |
// this js file with the hope they'll get loaded elsewhere. Require also allows you to create | |
// site wide dependencies so you don't have to include common libs like JQuery/JQueryUI in every js | |
// file. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment