[英]using stickytableheaders with requirejs not loading
I am trying to load stickytableheaders with requirejs and can't seem to get it to work. 我正在尝试用requirejs加载stickytableheaders ,但似乎无法使其正常工作。 Always says that it's not found. 总是说找不到。 I have confirmed it's loading that script prior to the use of it. 我已经确认它是在使用脚本之前先加载该脚本的。
any idea why $("table").stickyTableHeaders();
任何想法为什么$("table").stickyTableHeaders();
would throw an undefined is not a function
error? 会抛出undefined is not a function
错误吗?
Config file 配置文件
var require = {
baseUrl: "/",
paths: {
"bootstrap": "Scripts/bootstrap/bootstrap",
"jquery": "Scripts/jquery/jquery-1.9.1",
"stickyTableHeaders": "Scripts/stickyheader/stickyheader",
"knockout": "Scripts/knockout/knockout-3.3.0",
"text": "Scripts/require/text",
"domReady": "Scripts/require/domReady"
},
shim: {
"bootstrap": {
deps: ["jquery"]
},
'stickyTableHeaders': {
deps: ['jquery'],
exports: 'jQuery.fn.stickyTableHeaders'
}
}
}
startup file 启动文件
require(['jquery'
, 'knockout'
, 'Scripts/App/components/appViewModel'
, 'stickyTableHeaders'
, 'bootstrap'
, '/Scripts/knockout/bindinghandlers.js'
, 'domReady!']
, function ($, ko, appViewModel, stickyTableHeaders) {
ko.components.register('reportingline', { require: 'Scripts/App/components/reportingline/line' });
ko.components.register('newrpt', { require: 'Scripts/App/components/newrpt/newreport' });
$("table").stickyTableHeaders();
ko.applyBindings(new appViewModel());
})
I was able to get it to work. 我能够使它正常工作。
I had to add the code to the end of the view model for the page that it was needed on. 我必须将代码添加到所需页面的视图模型的末尾。 Seems there should be a way to do it globally though. 似乎应该有一种全球性的方法。
$("table").stickyTableHeaders(); $(“ table”)。stickyTableHeaders();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.