【发布时间】:2015-05-16 21:16:53
【问题描述】:
我的应用卡住了。我想使用函数之类的变量创建自己的reports.js 文件,但我无法对其进行初始化。我正在复制模板中已经完成的其他模板,但我不明白为什么我的不起作用。
这是我称之为头部的部分。
$(document).ready(function(){
"use strict";
App.init(); // Init layout and core plugins
Plugins.init(); // Init all plugins
FormComponents.init(); // Init all form-specific plugins
Reports.init();
$('#StartDate').pickadate({
formatSubmit: 'yyyy/mm/dd',
hiddenName: true
});
});
当我运行网站时,控制台显示 TypeError: Reports.init 不是函数
现在我要分享 report.js 文件:
var Reports = function () {
"use strict";
var form = $('form').attr('id');
alert(form);
/* * * * * * * * * * * * * * *
* Employee Clock-In Clock-Out
* * * * * * * * * * * * * * */
var EmployeeClocks = function(form) {
// will do something
}
return {
// main function to initiate reports
init: function () {
// EmployeeClocks();
},
};
}
【问题讨论】:
-
可能希望将“使用严格”移到 $(document) 上方。准备好。如果将它放在脚本的顶部,则不需要在每个函数中调用它
标签: javascript jquery function initialization init