How to use requirejs in client side
http://requirejs.org/
1. in html
<script data-main="js/main" src="js/require.js"></script>
main.js is the entry point of our app logic
2. in main.js
//config requirejs parameter
requirejs.config({
baseUrl: 'js' //this is the base folder, so we can use jquery not js/jquery
});
requirejs(['jquery', 'DataBinder','jquery.blockUI', 'bootstrap.min'], // these are dependency will load async
function ($, Model) {
//define inner function and var here
return {}; // return the object we want to export
});
3. define your own module, ex. DataBinder.js
define(["jquery"], function (jQuery) {
//define inner function and var here
return {}; // return the object we want to export
});