I am trying to load stickytableheaders with requirejs and can't seem to get it to work. 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();
would throw an undefined is not a function
error?
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.