Friday, August 30, 2013

Use Non AMD Javascript Libraries in Durandal 2.0


By using shim, jquery libraries can be used in Durandal.

In the main js, configure shim. I have written a module UIInitialize to intialize the interface. This is dependant on jQuery, jQueryGritter and jQueryPulsate.

requirejs.config({
    urlArgs: "bust=" + (new Date()).getTime(),
    paths: {
        'text': '../Scripts/text',
        'durandal': '../Scripts/durandal',
        'plugins': '../Scripts/durandal/plugins',
        'transitions': '../Scripts/durandal/transitions',
        'jQueryGritter': '../Scripts/gritter/js/jquery.gritter',
        'jQueryPulsate': '../Scripts/jquery.pulsate.min',
        'UIInitialize': '../Scripts/UIGeneral',
    },
    shim: {
        'UIInitialize': {
            deps: ['jquery', 'jQueryGritter', 'jQueryPulsate'],
            exports: 'UIInitialize'
        }
    }
});

The UIInitialize.js is as below:

var UIInitialize = function () {
    return {
          init: function () { 
               // Initialize gritter and pulsate
          }
    };
}();


1 comments:

Anonymous said...

can you please look at my question
http://stackoverflow.com/questions/24559718/some-java-script-seems-to-be-overwritten-by-durandal