I'm newby in require.js.
I have next trouble.
I linked require.js :
<script data-main="/Scripts/page/main" src="/Scripts/framework/require.js"></script>
code main.js
require.config(
{
shim: {
backbone: {
exports: 'backbone'
}
},paths: {
jquery: "/Scripts/framework/jquery/jquery-1.6.4",
underscore: "/Scripts/framework/underscore/underscore",
backbone: "/Scripts/framework/backbone/backbone"
}
});
require(["jquery"], function (jquery) {
// why jquery is undefined?
})
I tried to use it like in manual, but unfortunately it's doesnt work. Why in require function jquery variable is undefined? Thanks for any help.
The problem is that your
baseUrl
, where requireJs will load the script from, is the one you specify in thedata-main
attribute. From the docs:According to this, your paths need to look like this:
You could also set the
baseUrl
to the root of your project like this: