RequireJS - 定制JS库不工作 [英] RequireJS - custom js-library not working
问题描述
我想包括我RequireJS-Config中的自定义JS库/脚本,但它似乎没有工作。所以,我希望有人能帮助我。我使用RequireJS在骨干网和把手的组合,所以只是提它...
I'm trying to include a custom js-library/script in my RequireJS-config but it doesnt seem to work. So I hope someone can help me out. I'm using RequireJS in combination with Backbone and Handlebars, so just to mention it...
在我需要的配置我有:
require.config({
paths: {
jquery: 'lib/jquery/jquery',
backbone: 'lib/backbone/backbone',
// Templating.
handlebars: 'lib/handlebars/handlebars',
// Plugins.
jqueryEffects: 'lib/jquery/jquery.effects',
... //some more libraries
},
shim: {
backbone: {
deps: ['jquery', 'lodash','jqueryEffects'],
exports: 'Backbone'
},
lodash: {
exports: '_'
},
handlebars: {
exports: 'Handlebars'
},
jqueryEffects : {
deps: ['jquery']
}
}
});
的 jquery.effects.js
是我创建了自己处理特殊事件的点击或运行动画等等。当我开始运行我的应用程序的骨干一个简单的脚本中,控制台告诉我,剧本被加载。所以现在我的意见之一,我已经呈现一个HTML文件,其中包含与作为一个标识符,点击后会触发一些......可是,什么也没有发生一类锚,所以我试图使警报在 jquery.effects.js
-file:
The jquery.effects.js
is a simple script i created my own to handle special click events or run animations etc. When i start to run my backbone app, the console tells me that the script is loaded. So now on one of my Views, I have rendered a HTML file which contains an anchor with a class which serves as an identifier, which after clicking it should trigger something...BUT, nothing happens, so I tried to make an alert in the jquery.effects.js
-file:
$(function() {
alert($(".videoname").lenght);
});
这给我的回应未定义
。有没有人可能有一个想法?这同样当我添加更多的图书馆,控制台说,他们被加载,但没有任何反应......?!?!?!??
This gave me the response undefined
. Does anyone maybe have an idea? The same goes when I add more libraries, console says they are loaded, but nothing happens... ?!?!?!??
推荐答案
试试这个(长度不lenght):
try this (length not lenght) :
(function() {
alert($(".videoname").length);
})();
这意味着你的脚本工作;)
That's means that your script is working ;)
这篇关于RequireJS - 定制JS库不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!