Joined August 2013
·
Achievements
29 Karma
0 Total ProTip Views
Forked
Have a project valued enough to be forked by someone else
Cub
Have at least one original jQuery or Prototype open source repo
Honey Badger
Have at least one original Node.js-specific repo
This errors occur if i use requirejs in chrome-extension. Without chrome-extension, also call over script-tag( <script data-main="js/main" src="js/lib/requirejs/require.js"></script> ) everything works well.
If i require('backbone') in test.js( see below ) i get an error --> Uncaught TypeError: Cannot call method 'each' of undefined ! i believe backbone cant call "each" method because underscore is not loaded completely ( see http://tinypic.com/view.php?pic=6j3a08&s=5 )
What am I doing wrong?
manifest.json file
{
"manifestversion": 2,
.....
.....
....
"contentscripts": [
{
"matches": ["<all_urls>"],
"js": [
"js/lib/requirejs/require.js",
"js/lib/requirejs/require-cs.js",
"js/main.js"
]
}
],
.....
.....
.....
}
main.js
requirejs.config({
baseUrl: chrome.extension.getURL("/"),
urlArgs: "v=" + (new Date()).getTime(),
paths: {
app : 'js/app',
jquery: 'js/lib/jquery/jquery',
backbone : 'js/lib/backbone/backbone',
underscore : 'js/lib/underscore/underscore'
},
shim : {
jquery : {
exports : '$'
},
backbone: {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
},
underscore : {
exports : '_'
}
}
});
require(['app/test'], function (test) {
console.log(test);
});
define() file test.js
define(function(require){
});