0

Hi my question is specific to libraries/plugins that depend on knockout.

Currently, I'm implementing requirejs in my existing project, a multi-page app.

This is what I currently have,

my common.js

require.config({
    baseUrl: '/Scripts/',
    paths: {
        ko: '/Scripts/lib/knockout-3.3.0',
        jquery: '/Scripts/jquery-1.10.2',
        domReady: '/Scripts/lib/domReady'
    }
});

file1.js

define(['ko', 'jquery'], function(ko, $){
  // code goes here
});

Above worked perfectly, until I need to use the knockoutjs-mapping (that I downloaded via nuget) plugin for knockout.

How will I include the knockoutjs-mapping in my project and make sure knockoutjs was loaded first before this or any 3rd party library. And how can I use it?

I tried something like this:

define(['ko', 'jquery', 'mapping'], function(ko, $, mapping) {
});

But not working,

And I saw this link but can't seem to figure out how to implement it. Any help would be much appreciated. Thanks

Boy Pasmo
  • 8,021
  • 13
  • 42
  • 67
  • On a general note, you might want to look into https://github.com/rniemeyer/knockout-amd-helpers – Tomalak Oct 26 '15 at 16:32
  • I tried the one that was suggested as duplicated question, the answer with most votes did not worked – Boy Pasmo Oct 26 '15 at 16:57
  • "Not working" is not an error description. Can you be a little bit more specific? – Tomalak Oct 26 '15 at 18:11
  • `define(['ko', 'jquery', 'mapping'], function(ko, $, mapping) { });` I did it like this but I said knockoutjs cannot be found and Im sure I included ko correctly in my config – Boy Pasmo Oct 27 '15 at 01:02
  • Read http://knockoutjs.com/documentation/amd-loading.html. I suspect that your knockout file is not really called `ko.js`. – Tomalak Oct 27 '15 at 09:44

0 Answers0