How do you use RequireJS in a .NET application?

I have the following folder structure:

-> order

  • charts
    • ... JS files
  • increase
    • ... JS files
  • common
    • ... JS files

-> Lib

  • JQuery
  • jquery.ui

jquery-1.7.2.js
requirejs-1.0.7.js
order.js

I have a .NET application with a lot of ascx control files that reference JS files in the traditional way, calling the JS file in a script tag, and then calling some function from that file.

The question is how should I (or can I) implement Require JS so that I can:

1) call the JS files. After all the images, css and html have been uploaded, and ...

2) use the AMD concept to modulate code

, aspx 5 ascx, ascx. ascx JavaScript , .master JavaScript.

- ( ), .

+5
3

... v. .

0

"InvokeScript()" - .NET. Google , - .

-, AMD, . , "InvokeScript()", :

define (... {
    var mySpecialHandler = function() {
        // do stuff
    };
    return {
      mySpecialHandler: mySpecialHandler
    }
});

, , , :

require(['app'], function (app) {
    window.mySpecialHandler = app.mySpecialHandler;
});
0
source

All Articles